CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Won't run Server command


New User

Feb 22, 2007, 11:13 AM

Post #1 of 4 (840 views)
Won't run Server command Can't Post


In this script I am try to first print the name of a file passed through to the script, and then run a 'dos2unix' command on any files passed through. The script runs, prints to a log file, but does not run the actually 'dos2unix file file' command to the server. Any help would be appreciated

my $basedir = "/iw-home/"; # base directory of Teamsite
my $filename = $ARGV[0]; # name of .txt file created on the fly for every deployment
my $mylogfile = "/app/data/teamsite-logs/admin_dos2unix.log"; #log of files command is run on
my $deployflyfile = $basedir . "OpenDeployNG/tmp/" . $filename;

open (MYINPUTFILE, "$deployflyfile") or die "Cannot Open file: $!";
open (MYLOGFILE, ">>$mylogfile") or die " Cannot Open file: $!";
my(@myarray) = <MYINPUTFILE>; # loops through array finding files deployed
foreach $inputfile (@myarray)
$inputfile = $basedir . $inputfile;
$filedate = `date +%Y%m%d%H%M`;
$dos2unixcmd = "dos2unix $inputfile $inputfile"; # runs dos2unix command on all files deployed
print MYLOGFILE "$filedate\n";
print MYLOGFILE "$dos2unixcmd\n"; # logs all files on which command was run

exit (0);


Feb 22, 2007, 4:28 PM

Post #2 of 4 (835 views)
Re: [crimirish] Won't run Server command [In reply to] Can't Post

Perhaps dos2unix can't be found (maybe your PATH doesn't include the directory it's in?) but you won't know as you aren't checking for errors.

Paul Wilson
ProBulletin Board:

New User

Feb 23, 2007, 6:38 AM

Post #3 of 4 (830 views)
Re: [ProBulletin] Won't run Server command [In reply to] Can't Post

when I print the output of `$dos2unix` such as my_cmd = `$dos2unix`; print MYLOGFILE my_cmd; It prints out the entire file I am trying to run the command on.

Thaumaturge / Moderator

Mar 1, 2007, 5:44 AM

Post #4 of 4 (806 views)
Re: [crimirish] Won't run Server command [In reply to] Can't Post

Don't use backticks to run an external program _unless_ you're collecting the output from that program.

Use "system" instead.

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives