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.

Recommended Answers

All 2 Replies

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

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!! ):

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.