how to use system command to launch a shell script ?

G

gniagnia

Hi all,

I've searched the www for hours but I still don't understand why this
isn't working.

I am writting a perl script (on a linux server) that needs to run a
shell script (on the same linux server).
So I tried the following :

1 - exec "/path/to/my/shell_script.sh";

2 - open EXIT, "/us/path/to/my/shell_script.sh |";

3 - system "/path/to/my/shell_script.sh";

Neither of these 3 attempts actually worked.....the shell script isnt
launched by the linux server....

What am i missing?

Thanks a lot in advance
 
J

Jürgen Exner

gniagnia said:
I am writting a perl script (on a linux server) that needs to run a
shell script (on the same linux server).
So I tried the following :

1 - exec "/path/to/my/shell_script.sh";

2 - open EXIT, "/us/path/to/my/shell_script.sh |";

3 - system "/path/to/my/shell_script.sh";

Neither of these 3 attempts actually worked.....the shell script isnt
launched by the linux server....

What am i missing?

You forgot to ask perl for help. Why are you ignoring the return value/error
codes?
See e.g. "perldoc -f system" for details about how to extract them

jue
 
G

gf

Hi all,

I've searched the www for hours but I still don't understand why this
isn't working.

I am writting a perl script (on a linux server) that needs to run a
shell script (on the same linux server).
So I tried the following :

1 - exec "/path/to/my/shell_script.sh";

2 - open EXIT, "/us/path/to/my/shell_script.sh |";

3 - system "/path/to/my/shell_script.sh";

Besides testing your return values and error codes, you might want to
do preflight tests to see if the script exists as you expect it, i.e.,
is it an executable file?

(-f "/path/to/my/shell_script.sh" && -x _) && exec "/path/to/my/
shell_script.sh"; ... or system() or `` or qx()

And don't forget the standard

use warnings;
use strict;

at the top of your code.
 
J

Joe Smith

gniagnia said:
Neither of these 3 attempts actually worked.....the shell script isnt
launched by the linux server....

Server? Is this a stealth CGI question? You should say so.

'perldoc -q CGI' shows a pointer to: http://www.perl.org/CGI_MetaFAQ.html

I wouldn't be surprised if it was the case where a process running as
user 'nobody' does not have permission to access files owned by 'gniagnia'.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top