User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 23 Jan 2003, 19:57   #1
Slidey
Registered User
 
Join Date: Mar 2001
Posts: 205
Slidey is an unknown quantity at this point
perl crap person requires shove in the right direction..

whats wrong with this:

Code:
my $logDir = "/var/log/httpd";
my $bkupDir = "$logDir/bak";

@mvargs = ("/bin/mv", '$logDir/*_log', "$bkupDir");

system(@mvargs) == 0 or die "Couldnt exec $!";
im getting the followign error:

Code:
/bin/mv: cannot stat `$logDir/*_log': No such file or directory
Couldnt exec  at axsl.pl line 24.
ive tried putting " around the argument too, but same thing happened... what do i have to do to expand the args ?

Slidey
__________________
#linux - home of idiots

#impulsed - home of genius..?
Slidey is offline   Reply With Quote
Unread 23 Jan 2003, 20:57   #2
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Check the perldoc for system. It only uses sh, and thus globbing, when given a string rather than a list. So either concatenate to a string, or use something like @mvargs = ("/bin/mv", glob '$logDir/*_log', "$bkupDir");
queball is offline   Reply With Quote
Unread 23 Jan 2003, 21:03   #3
zenopus
Xenoc
 
Join Date: Feb 2001
Location: Great Britain
Posts: 297
zenopus is an unknown quantity at this point
alternatively
Code:
my @mvargs = ('/bin/mv', "$logDir/*_log", "$bkupDir" );
my $mvcmd = join ' ',@mvargs;

system($mvcmd) == 0 or die "Couldnt exec $!";
zenopus is offline   Reply With Quote
Unread 23 Jan 2003, 22:23   #4
Atamur
Ngisne
 
Join Date: Jul 2001
Location: right here
Posts: 79
Atamur is an unknown quantity at this point
Re: perl crap person requires shove in the right direction..

Quote:
Originally posted by Slidey
whats wrong with this:

Code:
......
@mvargs = ("/bin/mv", '$logDir/*_log', "$bkupDir");
.........
variable is not interpolated inside single quotes around $logDir/*_log. replace with double quotes.
__________________
down with signatures
Atamur is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 12:54.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018