Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

qx not find file with full path name

Status
Not open for further replies.

grazinggoat

Programmer
Mar 12, 2008
41
US
When i execute the script I get the following error:

./run.pl

sh: ls -l /tmp/var/a.log: No such file or directory
sh: ls -l /tmp/var/b.log: No such file or directory
sh: ls -l /tmp/var/c.log: No such file or directory

Seems its bombing on the qx but why wouldn't it find
the filenames they are there? Any thought. Thnx Gents!


$aLog = "/tmp/var/a.log";
$bLog = "/tmp/var/b.log";
$cLog = "/tmp/var/c.log";

my @files = ( $aLog, $bLog, $cLog );

foreach $f (@files) {
chomp($f);
$LogSize = qx("ls -l $f");
( $LS_FSIZE ) = (split)[4];
if ( $LS_FSIZE > 5000000 ) {
system("/bin/gzip -9 $f");
system("/bin/mv $f.gz /logs/$f.gz");

print "log moved..\n";
}
} # End foreach Loop
exit 0;
 
You don't need the " quotes as well as the qx, since qx is effectively a type of quotes. Perl is trying to locate and run a command called "ls -l /tmp/var/a.log" (i.e. with spaces in it) instead of running ls with -l /tmp/var/a.log as parameters.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top