Hi,
I tried to retreive ncftpget ouptut using backticks in a variable or even in an array. The output of the command is displayed to STDOUT but nothing is put in the variable. What's wrong ?
Zephan
backticks capture the stdout of the command, you sure the information you want isn't coming back through stderr? If that's the case, try a bit of redirection and put 2>&1 after your command inside the backticks. Most shells support this.
________________________________________
Andrew - Perl Monkey
Thanks, icrf, actually it is my mistake when there are really an error. but the 2>&1 I added wont to print the :
/home/user/file06032004.txt: 1.48 kB 45.28 kB/s
output line when transfere is successfull.
Even better then backticks or system is using the appropriate perl commands to accomplish the task
Net::FTP for ftp related info
opendir() for ls style info
etc etc etc
Backticks and System are generally not the best if security and performance are concerns. I understand the need for it, I use when required, but if there is an alternative native perl method its best to go that route.
There's also another way...if you want to watch/parse the output of the executed command as it's happening and not just wait for it to end to get all the output (like backticks) you can use open...you can get the exit status, the output, and even a sub-process pid...it's the only way to go for things that may wedge or you want to see it as it happens...:
$pid_of_sub_process = open(CMD,"SomeCommandName |");
while(<CMD>) {
print "--> $_";
if (/Some Thing Which Means Its Messed Up/) {close CMD}
}
close(CMD);
$stat = $? >> 8; # did it exit with status?
if ($stat) {die "exited with status $stat"}
I will toss in my two cents here. I tend to look at things from a 'loaded server' perspective (~1 million hits a day +). If you are not anticipating high traffic opening named pipes works well.
But as load increases (~250k+ page views a day) named pipes will take a significant toll on your resources.
Thats been my experience. Your mileage may vary Sorry CadGuy, not saying your solution is not nice, its very nice, I've just been eaten by named pipes before so I am gunshy.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.