Professional Web Applications Themes

Passing options to command in a system call - PERL Beginners

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...

  1. #1

    Default 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
    Jan Guest

  2. #2

    Default RE: Passing options to command in a system call

    Jan Eden wrote: 

    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')
    Bob Guest

  3. #3

    Default 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 <org> 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: org
    For additional commands, e-mail: org





    __________________________________________________
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    http://mail.
    Doug Guest

  4. #4

    Default Re: Passing options to command in a system call

    On Fri, 1 Oct 2004 17:41:50 +0200, Jan Eden <org> wrote: 

    Hello!

    <<SNIP>>
     

    This is ironic:
     

    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
    Errin Guest

  5. Moderated Post

    Default Re: Passing options to command in a system call

    Removed by Administrator
    Jan Guest
    Moderated Post

Similar Threads

  1. Replies: 1
    Last Post: May 30th, 09:28 AM
  2. Paypal Command Options?
    By Onideus in forum Macromedia Flash
    Replies: 49
    Last Post: March 13th, 04:41 PM
  3. Options for passing Hash to a subroutine.
    By chung.ley@amd.com in forum PERL Modules
    Replies: 6
    Last Post: April 4th, 04:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139