Running scripts from another directory

Posted by Desmond Hume on Super User See other posts from Super User or by Desmond Hume
Published on 2012-11-24T22:35:59Z Indexed on 2012/11/24 23:06 UTC
Read the original article Hit count: 464

Filed under:
|
|
|
|

Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it.

Is it a good practice to run scripts (BASH, Perl etc.) from another directory? Will they usually find all the stuff they need to run properly?

If so, what is the best way to run a "distant" script? Is it

. /path/to/script

or

sh /path/to/script

and how to use sudo in such cases? This, for example, doesn't work:

sudo . /path/to/script

© Super User or respective owner

Running scripts from another directory

Posted by Desmond Hume on Ask Ubuntu See other posts from Ask Ubuntu or by Desmond Hume
Published on 2012-11-24T22:36:06Z Indexed on 2012/11/24 23:19 UTC
Read the original article Hit count: 464

Filed under:
|

Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it.

Is it a good practice to run scripts (BASH, Perl etc.) from another directory? Will they usually find all the stuff they need to run properly?

If so, what is the best way to run a "distant" script? Is it

. /path/to/script

or

sh /path/to/script

and how to use sudo in such cases? This, for example, doesn't work:

sudo . /path/to/script

© Ask Ubuntu or respective owner

Related posts about linux

Related posts about command-line