Find the answer to your Linux question:
Results 1 to 4 of 4
Hi Guys, I'm getting a weird problem here. So, below is description of it. 1. $PATH=/tools/bin/ /tools/bin/myscript contains the following echo $0 Code: $ myscript And the output I get ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Location
    Bangalore , India
    Posts
    29

    $0 in bash shell script expanding to full path


    Hi Guys,
    I'm getting a weird problem here. So, below is description of it.
    1. $PATH=/tools/bin/

    /tools/bin/myscript contains the following
    echo $0

    Code:
    $ myscript
    And the output I get is
    Code:
    $  /tools/bin/myscript
    shouldn't it be myscript?

    2. This is where it gets very weird
    The above /tools/bin/myscript is on a NFS mounted directory. If i do the same thing on a local disk then the out put is "myscript"

    Can anyone tell me why this is?

    Thanks

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,763
    Sorry,I couldn't understand the question. Are you saying you are getting different output with same script when executing from local file system & nfs ?
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  3. #3
    Just Joined!
    Join Date
    Jun 2006
    Location
    Bangalore , India
    Posts
    29
    Yes it is the same script on different locations
    /tools/bin/myscript is on a nfs mounted disk
    /media/tools/bin/myscript is on a local disk

    so if do
    $ cd /tools/bin/
    $ ./myscript
    $ /tools/bin/myscript

    $ cd /media/tools/bin/
    $ ./myscript
    $ myscript

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,763
    hmm..thats strange..I tried the same script .. on both nfs & local/native file system. Both of them gave me same result/output "myscript.sh"
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •