-2

I want to do

/usr/bin/bash myscript.sh -args

which, as it stands, runs the script but doesn't pass the args to it. I realize that the conventional syntax is simply

./myscript.sh -args

but I'm curious as to what I need to do in order to call the script from bash explicitly.

2
  • 4
    Works fine here. Jun 11, 2010 at 21:16
  • Works fine for me. Perhaps if you showed your script we'd be better able to diagnose the problem. Also, what version of Bash? Jun 11, 2010 at 21:49

2 Answers 2

1

Try running the script in debug output mode

/usr/bin/bash --verbose myscript.sh -args
0

Please provide information about your operating system. Having 'bash' located at "/usr/bin/bash" tips me off that you're probably not running one of the more common GNU/Linux distributions.

On that note, what does the she-bang of the script look like? If it's any different from the following, then you're not doing the equivalent with your bash command:

#!/usr/bin/bash

One other suggestion I can pull out of the blue is to try escaping the parameters to bash, just in case there's some strange getopt thing going on.

/usr/bin/bash -- myscript.sh -args
1
  • And change permission so the file can be executed: chmod a+x file (or u+x if you want make it executable only to the user)
    – PiL
    Jul 12, 2010 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .