Scripts not working. - Unix

This is a discussion on Scripts not working. - Unix ; Having problem with scripting, they are not running. I dont get any kind of error as well. my PATH=/usr/bin:/bin:/script; and simple script is #!/bin/sh myvar = test echo " you typed $myvar" this file is in my 'scrpit' directory with ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Scripts not working.

  1. Scripts not working.

    Having problem with scripting, they are not running. I dont get any
    kind of error as well.

    my PATH=/usr/bin:/bin:/script;

    and simple script is

    #!/bin/sh

    myvar = test
    echo " you typed $myvar"

    this file is in my 'scrpit' directory with 'test' name; given it chmod
    777 test.

    when i am running it give me nothing at all...

    sh file is in bin directory. tried running it as root
    and as user still not working, any idea.

    Thanks


  2. Re: Scripts not working.

    On 7 Mar 2006 17:35:43 -0800, aasim.ajaz@gmail.com wrote:
    > Having problem with scripting, they are not running. I dont get any
    > kind of error as well.
    >
    > my PATH=/usr/bin:/bin:/script;
    >
    > and simple script is
    >
    > #!/bin/sh
    >
    > myvar = test
    > echo " you typed $myvar"
    >
    > this file is in my 'scrpit' directory with 'test' name; given it chmod
    > 777 test.


    I would not use the word _test_ for anything (names, vars,...).

    > when i am running it give me nothing at all...


    I usually put
    set -vx as second line of script.

    set - as next to last


  3. Re: Scripts not working.

    myvar = joe
    + myvar = joe
    /script/work: myvar: not found
    echo "you typed $myvar"
    + echo you typed
    you typed

    This is what i am getting now ... changed the file to work and used set
    -vx.



    Bit Twister wrote:
    > On 7 Mar 2006 17:35:43 -0800, aasim.ajaz@gmail.com wrote:
    > > Having problem with scripting, they are not running. I dont get any
    > > kind of error as well.
    > >
    > > my PATH=/usr/bin:/bin:/script;
    > >
    > > and simple script is
    > >
    > > #!/bin/sh
    > >
    > > myvar = test
    > > echo " you typed $myvar"
    > >
    > > this file is in my 'scrpit' directory with 'test' name; given it chmod
    > > 777 test.

    >
    > I would not use the word _test_ for anything (names, vars,...).
    >
    > > when i am running it give me nothing at all...

    >
    > I usually put
    > set -vx as second line of script.
    >
    > set - as next to last



  4. Re: Scripts not working.

    On 7 Mar 2006 17:58:13 -0800, Aasim Ajaz wrote:
    > myvar = joe
    > + myvar = joe
    > /script/work: myvar: not found


    Now, I suggest some reading here, even though I know you are using sh.

    ! bash script introduction documentation
    http://tldp.org/LDP/intro-linux/html/index.html

    ! bash script advanced documentation
    http://tldp.org/LDP/abs/html/index.html

  5. Re: Scripts not working.

    On 2006-03-08, aasim.ajaz@gmail.com wrote:
    > Having problem with scripting, they are not running. I dont get any
    > kind of error as well.
    >
    > my PATH=/usr/bin:/bin:/script;


    Is it really /script and not $HOME/script?

    > and simple script is
    >
    > #!/bin/sh
    >
    > myvar = test


    Incorrect; that line will try to execute a command named "myvar"
    with two arguments, "=" and "test". You should use:

    myvar=test

    > echo " you typed $myvar"
    >
    > this file is in my 'scrpit' directory with 'test' name; given it chmod
    > 777 test.
    >
    > when i am running it give me nothing at all...
    >
    > sh file is in bin directory. tried running it as root
    > and as user still not working, any idea.


    To see what your shell will execute if you type "test" at the
    command line, use:

    command -V test

    Or:

    type test

    Usually, it will be a shell builtin, not your script. If you want
    to call your script "test" (not a good idea), you will have to use
    the full path to it:

    /script/test

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  6. Re: Scripts not working.

    Thank guys... problem was with the spaces. myvar=test... worked.


  7. Re: Scripts not working.

    Aasim Ajaz wrote:
    > myvar = joe
    > + myvar = joe
    > /script/work: myvar: not found


    use
    myvar=joe

    - no spaces after myvar. Otherwise shell wants to execute program "myvar"
    (not found) and pass arguments "=" and "joe" to it.

    > echo "you typed $myvar"
    > + echo you typed
    > you typed


    --
    Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
    Warning: I wish NOT to receive e-mail advertising to this address.
    Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
    Your mouse has moved. Windows NT will now restart for changes to take
    to take effect. [OK]

+ Reply to Thread