+ Reply to Thread
Results 1 to 5 of 5

How to "test" shell script without running it?

  1. How to "test" shell script without running it?

    I seem to remember with the korn shell a switch that would syntactically
    evaluate the script reporting any errors but NOT run the script.

    Is something like this available with bash?

    If so, please advise? I've looked through the bash docs and man pages but
    cannot seem to find anything.

    TIA

  2. Re: How to "test" shell script without running it?

    Use the -n option:

    bash -n script

    In vim I have a ksh script called compile tied to F4.
    It determines the type of script and calls the appropriate
    routine (ksh -n for ksh, perl -c for perl).

    It has saved me endless agony over the years.

    Dan Mercer

    "bobmct" wrote in message news:4Lduh.1$ji5.4167@news.ntplx.net...
    : I seem to remember with the korn shell a switch that would syntactically
    : evaluate the script reporting any errors but NOT run the script.
    :
    : Is something like this available with bash?
    :
    : If so, please advise? I've looked through the bash docs and man pages but
    : cannot seem to find anything.
    :
    : TIA



  3. Re: How to "test" shell script without running it?

    Dan Mercer wrote:

    > Use the -n option:
    >
    > bash -n script
    >
    > In vim I have a ksh script called compile tied to F4.
    > It determines the type of script and calls the appropriate
    > routine (ksh -n for ksh, perl -c for perl).
    >
    > It has saved me endless agony over the years.
    >
    > Dan Mercer
    >


    Thanks, Dan;

    That's what I was looking for! Funny, thought, I still don't see reference
    to it int he bash docs...

    But, it does what I was looking for.

    Thanks again.

    bobmct

  4. Re: How to "test" shell script without running it?


    Hi bob,

    For the K shell what is option we need to choice just for the systax
    checking , is ksh -n script ???,is this way u r testing ....

    Regards
    Gori Akthar



    On Jan 26, 6:05 pm, bobmct wrote:
    > Dan Mercer wrote:
    > > Use the -n option:

    >
    > > bash -n script

    >
    > > In vim I have a ksh script called compile tied to F4.
    > > It determines the type of script and calls the appropriate
    > > routine (ksh -n for ksh, perl -c for perl).

    >
    > > It has saved me endless agony over the years.

    >
    > > Dan MercerThanks, Dan;

    >
    > That's what I was looking for! Funny, thought, I still don't see reference
    > to it int he bash docs...
    >
    > But, it does what I was looking for.
    >
    > Thanks again.
    >
    > bobmct



  5. Re: How to "test" shell script without running it?

    On Jan 29, 8:04 pm, "oracle DBA" wrote:
    > Hi bob,
    >
    > For the K shell what is option we need to choice just for the systax
    > checking , is ksh -n script ???,is this way u r testing ....
    >
    > Regards
    > Gori Akthar
    >
    > On Jan 26, 6:05 pm, bobmct wrote:
    >
    > > Dan Mercer wrote:
    > > > Use the -n option:

    >
    > > > bash -n script

    >
    > > > In vim I have a ksh script called compile tied to F4.
    > > > It determines the type of script and calls the appropriate
    > > > routine (ksh -n for ksh, perl -c for perl).

    >
    > > > It has saved me endless agony over the years.

    >
    > > > Dan MercerThanks, Dan;

    >
    > > That's what I was looking for! Funny, thought, I still don't see reference
    > > to it int he bash docs...

    >
    > > But, it does what I was looking for.

    >
    > > Thanks again.

    >
    > > bobmct



    Very Good for "test" shell script. Below is my output.

    moonhk@hex:/mnt/disk2/ux3/shell$ ksh -n xall.ksh
    xall.ksh: warning: line 18: `...` obsolete, use $(...)
    xall.ksh: warning: line 19: `...` obsolete, use $(...)
    xall.ksh: warning: line 20: `...` obsolete, use $(...)
    xall.ksh: warning: line 26: `...` obsolete, use $(...)
    xall.ksh: warning: line 30: `...` obsolete, use $(...)
    xall.ksh: warning: line 32: `...` obsolete, use $(...)
    xall.ksh: warning: line 35: `...` obsolete, use $(...)
    xall.ksh: warning: line 40: `...` obsolete, use $(...)
    xall.ksh: warning: line 40: `...` obsolete, use $(...)
    xall.ksh: warning: line 67: `...` obsolete, use $(...)
    moonhk@hex:/mnt/disk2/ux3/shell$

    xclient=`ps -ef | grep progres | grep /data | wc -l`





+ Reply to Thread