Why do I get the message set no match when I run this script?












1















#! /usr/bin/tcsh -f

set ps_output = "`ps -u $user`"
@ i = 2

echo "$ps_output"

set ps_test

while ( $i <= $#ps_output )
set line = ( $ps_output[$i] )
if ( $line[4] != "ps" && $line[4] != "tcsh" && $line[4] != "zap" ) then
set ps_test = ( $ps_test $i )
endif
@ i ++
end

foreach i ( $ps_test )
set line = ( $ps_output[$i] )
set process_no = $line[1]
if ( $line[4] == "HAL9000" || $line[4] == "HALos" || $line[4] == "HALshell" || $line[4] == "HALkeyboardDriv" || $line[4] == "HALdisplayDrive" || $line[4] == "HALdiskDriver" ) then
kill -9 $process_no
endif
end


exit 0


So I keep getting the set no match error in my script, but i couldn't find which set is responsible for that , I mean even when I commented out
set ps_test , I still get a no set match, is there a way to fix this










share|improve this question




















  • 3





    Quite frankly, your first error is scripting in tcsh :). Even the tcsh FAQ itself links to the famous essay on why the csh family of shells shouldn't be used for scripting. That said, the way to debug this sort of thing is to add echo statements everywhere and see what values your variables are taking. In my case, it choked on ps lines containing ? which, I think, was treated as a glob and changed the value I was setting.

    – terdon
    Jan 22 '16 at 10:40






  • 1





    What @terdon said. I suspect you're running into a case of accidental globbing, though. Try adding set noglob to the top of the script.

    – Martin Tournoij
    Jan 22 '16 at 16:21
















1















#! /usr/bin/tcsh -f

set ps_output = "`ps -u $user`"
@ i = 2

echo "$ps_output"

set ps_test

while ( $i <= $#ps_output )
set line = ( $ps_output[$i] )
if ( $line[4] != "ps" && $line[4] != "tcsh" && $line[4] != "zap" ) then
set ps_test = ( $ps_test $i )
endif
@ i ++
end

foreach i ( $ps_test )
set line = ( $ps_output[$i] )
set process_no = $line[1]
if ( $line[4] == "HAL9000" || $line[4] == "HALos" || $line[4] == "HALshell" || $line[4] == "HALkeyboardDriv" || $line[4] == "HALdisplayDrive" || $line[4] == "HALdiskDriver" ) then
kill -9 $process_no
endif
end


exit 0


So I keep getting the set no match error in my script, but i couldn't find which set is responsible for that , I mean even when I commented out
set ps_test , I still get a no set match, is there a way to fix this










share|improve this question




















  • 3





    Quite frankly, your first error is scripting in tcsh :). Even the tcsh FAQ itself links to the famous essay on why the csh family of shells shouldn't be used for scripting. That said, the way to debug this sort of thing is to add echo statements everywhere and see what values your variables are taking. In my case, it choked on ps lines containing ? which, I think, was treated as a glob and changed the value I was setting.

    – terdon
    Jan 22 '16 at 10:40






  • 1





    What @terdon said. I suspect you're running into a case of accidental globbing, though. Try adding set noglob to the top of the script.

    – Martin Tournoij
    Jan 22 '16 at 16:21














1












1








1








#! /usr/bin/tcsh -f

set ps_output = "`ps -u $user`"
@ i = 2

echo "$ps_output"

set ps_test

while ( $i <= $#ps_output )
set line = ( $ps_output[$i] )
if ( $line[4] != "ps" && $line[4] != "tcsh" && $line[4] != "zap" ) then
set ps_test = ( $ps_test $i )
endif
@ i ++
end

foreach i ( $ps_test )
set line = ( $ps_output[$i] )
set process_no = $line[1]
if ( $line[4] == "HAL9000" || $line[4] == "HALos" || $line[4] == "HALshell" || $line[4] == "HALkeyboardDriv" || $line[4] == "HALdisplayDrive" || $line[4] == "HALdiskDriver" ) then
kill -9 $process_no
endif
end


exit 0


So I keep getting the set no match error in my script, but i couldn't find which set is responsible for that , I mean even when I commented out
set ps_test , I still get a no set match, is there a way to fix this










share|improve this question
















#! /usr/bin/tcsh -f

set ps_output = "`ps -u $user`"
@ i = 2

echo "$ps_output"

set ps_test

while ( $i <= $#ps_output )
set line = ( $ps_output[$i] )
if ( $line[4] != "ps" && $line[4] != "tcsh" && $line[4] != "zap" ) then
set ps_test = ( $ps_test $i )
endif
@ i ++
end

foreach i ( $ps_test )
set line = ( $ps_output[$i] )
set process_no = $line[1]
if ( $line[4] == "HAL9000" || $line[4] == "HALos" || $line[4] == "HALshell" || $line[4] == "HALkeyboardDriv" || $line[4] == "HALdisplayDrive" || $line[4] == "HALdiskDriver" ) then
kill -9 $process_no
endif
end


exit 0


So I keep getting the set no match error in my script, but i couldn't find which set is responsible for that , I mean even when I commented out
set ps_test , I still get a no set match, is there a way to fix this







shell-script ps tcsh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 27 '16 at 14:22









Anthon

60.7k17102166




60.7k17102166










asked Jan 22 '16 at 5:51









alkabaryalkabary

5941023




5941023








  • 3





    Quite frankly, your first error is scripting in tcsh :). Even the tcsh FAQ itself links to the famous essay on why the csh family of shells shouldn't be used for scripting. That said, the way to debug this sort of thing is to add echo statements everywhere and see what values your variables are taking. In my case, it choked on ps lines containing ? which, I think, was treated as a glob and changed the value I was setting.

    – terdon
    Jan 22 '16 at 10:40






  • 1





    What @terdon said. I suspect you're running into a case of accidental globbing, though. Try adding set noglob to the top of the script.

    – Martin Tournoij
    Jan 22 '16 at 16:21














  • 3





    Quite frankly, your first error is scripting in tcsh :). Even the tcsh FAQ itself links to the famous essay on why the csh family of shells shouldn't be used for scripting. That said, the way to debug this sort of thing is to add echo statements everywhere and see what values your variables are taking. In my case, it choked on ps lines containing ? which, I think, was treated as a glob and changed the value I was setting.

    – terdon
    Jan 22 '16 at 10:40






  • 1





    What @terdon said. I suspect you're running into a case of accidental globbing, though. Try adding set noglob to the top of the script.

    – Martin Tournoij
    Jan 22 '16 at 16:21








3




3





Quite frankly, your first error is scripting in tcsh :). Even the tcsh FAQ itself links to the famous essay on why the csh family of shells shouldn't be used for scripting. That said, the way to debug this sort of thing is to add echo statements everywhere and see what values your variables are taking. In my case, it choked on ps lines containing ? which, I think, was treated as a glob and changed the value I was setting.

– terdon
Jan 22 '16 at 10:40





Quite frankly, your first error is scripting in tcsh :). Even the tcsh FAQ itself links to the famous essay on why the csh family of shells shouldn't be used for scripting. That said, the way to debug this sort of thing is to add echo statements everywhere and see what values your variables are taking. In my case, it choked on ps lines containing ? which, I think, was treated as a glob and changed the value I was setting.

– terdon
Jan 22 '16 at 10:40




1




1





What @terdon said. I suspect you're running into a case of accidental globbing, though. Try adding set noglob to the top of the script.

– Martin Tournoij
Jan 22 '16 at 16:21





What @terdon said. I suspect you're running into a case of accidental globbing, though. Try adding set noglob to the top of the script.

– Martin Tournoij
Jan 22 '16 at 16:21










1 Answer
1






active

oldest

votes


















0














An alternative is to use pkill on one line either on the command line or in a script.



pkill -9 -u $USER '(HAL9000|HALos|HALshell|HALkeyboardDrv||HALdisplayDrive|HALdiskDriver)'





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f256936%2fwhy-do-i-get-the-message-set-no-match-when-i-run-this-script%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    An alternative is to use pkill on one line either on the command line or in a script.



    pkill -9 -u $USER '(HAL9000|HALos|HALshell|HALkeyboardDrv||HALdisplayDrive|HALdiskDriver)'





    share|improve this answer




























      0














      An alternative is to use pkill on one line either on the command line or in a script.



      pkill -9 -u $USER '(HAL9000|HALos|HALshell|HALkeyboardDrv||HALdisplayDrive|HALdiskDriver)'





      share|improve this answer


























        0












        0








        0







        An alternative is to use pkill on one line either on the command line or in a script.



        pkill -9 -u $USER '(HAL9000|HALos|HALshell|HALkeyboardDrv||HALdisplayDrive|HALdiskDriver)'





        share|improve this answer













        An alternative is to use pkill on one line either on the command line or in a script.



        pkill -9 -u $USER '(HAL9000|HALos|HALshell|HALkeyboardDrv||HALdisplayDrive|HALdiskDriver)'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 23 '16 at 20:36









        Craig SmallCraig Small

        48626




        48626






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f256936%2fwhy-do-i-get-the-message-set-no-match-when-i-run-this-script%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀