Summary: system("lynx -dump") command in Perl

From: A. Mahendra Rajah (Mahendra.Rajah@URegina.CA)
Date: Wed Oct 05 2005 - 14:07:39 EDT


  I asked why the following Perl statements would not produce
  the text file as desired using lynx:

  @Cmd = ($LYNX, "-cfg=$LYNX_CFG", "-dump ./$HTMLfile >| $TXTfile");
  $Stat = system(@Cmd);

  My thanks to these folks for taking the time to reply:
        Charles Ballowe
        "J.A. Gutierrez"
        Dr. Tim Cutts
        "Farmer, John"

  The following email from Dr Tim Cutts gives the complete answer
  to my problem:

...................................................................

  $Cmd = "$LYNX -cfg=$LYNX_CFG -dump ./$HTMLfile > $TXTfile";
  $Stat = system($Cmd);

  Would work. >| doesn't mean anything in bourne shell syntax,
  which is what system() uses. Secondly, you can't use shell
  metacharacters if the arguments to system() are a list, because
  in list form, it just calls exec(2), and no intervening shell,
  so what would happen in your code is that lynx would be called
  with two arguments

  '-cfg=something'

  and

  '-dump ./something_else >| something_again'

  Which it probably doesn't understand. See the perlfunc manpage
  entry for system, and also look at the manpage for the exec(3)
  C-library function, which will help you understand when an
  intervening shell is used and when it isn't.
...................................................................

  Thanks again for everyone who answered.

  -- mahendra
................................................................
  A. Mahendra Rajah Email: Mahendra.Rajah@URegina.CA
  Tru64 UNIX Systems Manager Phone: (306) 585-4496
  Dept. of Computing Services FAX: (306) 337-2324
  University of Regina,
  Regina, Sask., S4S 0A2
  Canada.
................................................................



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:50:24 EDT