execute ksh script in perl

Thread Solved

Join Date: Sep 2007
Posts: 25
Reputation: axn is an unknown quantity at this point 
Solved Threads: 0
axn axn is offline Offline
Light Poster

execute ksh script in perl

 
0
  #1
Oct 12th, 2009
I am migrating scripts from UNIX server to a Linux. In the perl script it calls rcp to transfer files. It worked ok in UNIX but not in Linux, which has scp, I dont want to do scp now as this is a temporary Linux Box I am using.
I wrote an ftp script to do the work which rcp was doing in UNIX so it would work in Linux. Testing the stand alone ftp works ok, call it within the perl script and it doesn't work

I have tried
system("ftpscript";
exec("./ftpscript");
system("./ftpscript";

ok whats another way to call a shell script within perl. I dont get any error messages. Destination directory does not contain any files.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 11
Reputation: Ghodmode is an unknown quantity at this point 
Solved Threads: 3
Ghodmode's Avatar
Ghodmode Ghodmode is offline Offline
Newbie Poster
 
0
  #2
Oct 13th, 2009
You can use back-quotes (`) or qx// . You should also redirect the standard error to the standard output in order to capture all of the output.

You might be running into a problem where one of the commands you execute from your shell script acts differently when it's executed from an interactive shell than it does when it's executed from within another script or by cron.

You won't get the output with either system() or exec() , but if you do use system() , you should probably check the exit status of the executed script via system's return value.

See http://perldoc.perl.org/functions/system.html and http://perldoc.perl.org/perlop.html#%60STRING%60

--
-- Ghodmode
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 25
Reputation: axn is an unknown quantity at this point 
Solved Threads: 0
axn axn is offline Offline
Light Poster
 
0
  #3
Oct 13th, 2009
got it to work. I had to full path it within the perl script. Below is the syntax

exec("/path/to/script/abcd");

i figured since both the perl and ksh were in the same directory it should run!! ):
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC