Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how to use system command to launch a shell script ?

Reply
Thread Tools

how to use system command to launch a shell script ?

 
 
gniagnia
Guest
Posts: n/a
 
      02-21-2007
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

 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      02-21-2007
gniagnia wrote:
> 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


 
Reply With Quote
 
 
 
 
gf
Guest
Posts: n/a
 
      02-21-2007
On Feb 21, 2:13 am, "gniagnia" <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      02-21-2007
gniagnia wrote:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Using subprocess module to launch a shell shell script that itselfforks a process Samuel A. Falvo II Python 0 10-08-2008 12:43 AM
Re: How to pass shell variable to shell script from python Christian Heimes Python 0 02-27-2008 10:53 AM
execute a shell script in a shell script moongeegee Perl Misc 2 12-04-2007 12:18 AM
can I run unix shell command in the ModelSim shell? clinton__bill@hotmail.com VHDL 2 02-18-2005 10:04 PM



Advertisments