Passing options to command in a system call
Hi, I try to call wget using system like this: system(wget -O /dev/null, http://janeden.org/test/file.txt;); This does not work: Can't exec wget -O /dev/null: No such file or directory at ./wgetrec.pl line 6. Ok, so how about this: system(wget, -O /dev/null http://janeden.org/test/file.txt;); No go: wget: missing URL Without additional options, system(wget, http://janeden.org/test/file.txt;); works fine. How can I pass an option to system's first argument in a setting like this? (I know I can use a module instead of calling wget, but this is a more general issue.) Thanks, Jan -- If all else fails read the instructions. - Donald Knuth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Passing options to command in a system call
Jan Eden wrote: Hi, I try to call wget using system like this: system(wget -O /dev/null, http://janeden.org/test/file.txt;); This does not work: Can't exec wget -O /dev/null: No such file or directory at ./wgetrec.pl line 6. Ok, so how about this: system(wget, -O /dev/null http://janeden.org/test/file.txt;); No go: wget: missing URL Without additional options, system(wget, http://janeden.org/test/file.txt;); works fine. How can I pass an option to system's first argument in a setting like this? This is explained in 'perldoc -f system' You either need to separate all the args yourself, or pass a single string to system so the shell can split the args. You're trying to do both. either: system(wget -O /dev/null http://janeden.org/test/file.txt;) or: system('wget', '-O', '/dev/null', 'http://janeden.org/test/file.txt') -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Passing options to command in a system call
I haven't used the wget program before, but try adding a comma after your -O. I did that and I got it working. Jan Eden [EMAIL PROTECTED] wrote:Hi, I try to call wget using system like this: system(wget -O /dev/null, http://janeden.org/test/file.txt;); This does not work: Can't exec wget -O /dev/null: No such file or directory at ./wgetrec.pl line 6. Ok, so how about this: system(wget, -O /dev/null http://janeden.org/test/file.txt;); No go: wget: missing URL Without additional options, system(wget, http://janeden.org/test/file.txt;); works fine. How can I pass an option to system's first argument in a setting like this? (I know I can use a module instead of calling wget, but this is a more general issue.) Thanks, Jan -- If all else fails read the instructions. - Donald Knuth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: Passing options to command in a system call
On Fri, 1 Oct 2004 17:41:50 +0200, Jan Eden [EMAIL PROTECTED] wrote: Hi, Hello! SNIP How can I pass an option to system's first argument in a setting like this? (I know I can use a module instead of calling wget, but this is a more general issue.) Thanks, Jan -- This is ironic: If all else fails read the instructions. - Donald Knuth First, check out 'perldoc -f system' The answer to you question is in the first paragraph! Second, try passing EACH argument as a seperate value: ((WARNING: I don't have wget, so I couldn't test this!)) system(wget, -O, /dev/null, http://janeden.org/test/file.txt;); --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Passing options to command in a system call
Thanks, Errin, Doug and Bob, Errin Larsen wrote on 01.10.2004: On Fri, 1 Oct 2004 17:41:50 +0200, Jan Eden [EMAIL PROTECTED] wrote: How can I pass an option to system's first argument in a setting like this? This is ironic: If all else fails read the instructions. - Donald Knuth First, check out 'perldoc -f system' The answer to you question is in the first paragraph! I *did* read the perldoc, of course. But I obviously misunderstood it and carefully avoided *both* working combination (single argument or four arguments to system). I thought that using three arguments (command, options, url) would cause Perl to execute wget -O /dev/null http://janeden.org Obviously, it only does this when getting the whole string split on whitespace *or* in one piece. Should have tried before wasting your time. Sorry. - Jan -- How many Microsoft engineers does it take to screw in a lightbulb? None. They just redefine dark as the new standard. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response