home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / perl / 7652 < prev    next >
Encoding:
Internet Message Format  |  1993-01-03  |  1.7 KB

  1. Path: sparky!uunet!think.com!spool.mu.edu!umn.edu!cybrspc!roy
  2. From: roy%cybrspc@cs.umn.edu (Roy M. Silvernail)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Copying files; system and exec for MS-DOS perl?
  5. Message-ID: <5ygswB5w165w@cybrspc.UUCP>
  6. Date: Sun, 03 Jan 93 00:53:03 CST
  7. References: <1993Jan2.220240.16046@athena.mit.edu>
  8. Organization: Villa CyberSpace, Minneapolis, MN
  9. Lines: 27
  10.  
  11. aeichsta@athena.mit.edu (Andrew J. Eichstaedt) writes:
  12.  
  13. > I'm using Len Reed's version of Perl for MS-DOS.  I wanted my perl script
  14. > simply to copy a file to another, new file.
  15. >
  16. > * Failing a built-in copy function, I thought I could do something like
  17. > system("copy $oldFile $newFile").  However, I can't seem to get system or
  18. > exec working in the version of perl I'm using.  A line like
  19. > perl -e "system('dir')" seems to do nothing in the DOS version, whereas 
  20. > perl -e "system('ls')" gives a directory (as I'd expect) when I try it on a
  21. > Unix machine.  Again, am I missing something obvious?
  22.  
  23. I'd say it's something obvious... :-)
  24.  
  25. It appears (and I'll have to do some experimenting to verify this) that
  26. perl is handling the system() call without a new instantiation of the
  27. command processor.  The 'dir' command is a builtin for command.com and
  28. 4dos, so it fails (since a new command shell wasn't spawned).  But 'ls'
  29. works because Unix shells typically have very few builtin commands.  The
  30. 'ls' calls the external command program 'ls', not a builtin shell
  31. command.
  32. --
  33. Roy M. Silvernail --  roy%cybrspc@cs.umn.edu - OR-  cybrspc!roy@cs.umn.edu
  34. #! /usr/bin/perl
  35.          open(I,"$0");@a=(<I>);shift(@a) until $a[0] =~ /^#!/;
  36.          open(I,">>$ENV{'HOME'}/.signature");print I @a;__END__
  37.          <perl signature virus V2.0 - do 'perl -x articlename'>
  38.