Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
4  
Works fine here. –  Ignacio Vazquez-Abrams Jun 11 '10 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? –  Dennis Williamson Jun 11 '10 at 21:49

2 Answers 2

Try running the script in debug output mode

/usr/bin/bash --verbose myscript.sh -args
share|improve this answer

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
share|improve this answer
    
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) –  Pier Jul 12 '10 at 7:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.