Ask a Question related to PERL Beginners, Design and Development.
-
Steve #1
system function wont redirect output
hey, in my program im just trying to redirect the commands output but i
get the error:
sh: line 1: 1: command not found
code:
$return = system("tar czvf $tar $files > $logfile >2&1");
if i take out the > $logfile >2&1 , it works fine but i get that error
with it in, but the werid thing is it did work before this is very
puzzling as i dont believe i changed anyhting and it did indeed work
before, now as i understand it Learning Perl 3rd Edition says if its a
simple cmd like ls then perl will just excute it if its anyhting more
complicated the shell will, but yeah i need to redirct the output any1
know why this isnt working as it should right?
thanks.
Steve Guest
-
Some 'System Calls' was Capturing system call output value
On Friday, Nov 14, 2003, at 18:39 US/Pacific, Jerry Rocteur wrote: Wiggins is the one who deserves the point, since he was the one with the... -
why wont my output work
<cfquery name="message" datasource="#Request.Site.DataSource#"> SELECT n.message, p.pagename from noticetext n, pages p WHERE... -
How to handle input and output of a program executed by System function in perl
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<JmBKc.4704$Iz3.2470@nwrddc01.gnilink.net>... Hi, I think Perl is good at dealing... -
redirect output to a file
Hi everybody I was wondering I've made a little script to make the 'w'-command a bit nicer to work with.. ---~/bin/w--- #/bin/bash cd w -sh... -
can't redirect output to a file?!
i wrote a simple program that read data from STDIN but redirected in a pipe from a file parse it and wrote output to STDOUT,here is the code: ... -
-
Matt #3
Re: system function wont redirect output
I figure this has been solved by the submitter at some time in the last 8 years ... but for completeness ....
system will take either a string or a list/array ... if a string is supplied it the system command will check the contents and determine if any shell meta-chars are included in it (.e.g. > < & ; ). If they are then the string is executed in a sub-shell, if they are not as simple exec is done...
So, for redirections it has to be the single-string version of the system command ...
But back to the original issue ... I reckon its a typo .... the syntax for redirecting STDERR into the same place as STDOUT is 2>&1 NOT >2&1
The typo causes the string is being mis-interpreted as 'redirect STDOUT into a file called '2' and put the job in the background, and then execute another command called '1'....
jMatt Guest



Reply With Quote


