There are times when simply copying a few files may appear straightforward,
but... 


To grab and see the command line that's really sent to the system, 
just use backticks and add 'echo' at the beginning of your command line, 
as in the following

my $line = `echo dir c:\\foo`; 
print $line ;

Once it get it ok, just remove the 'echo' 
You can then still keep printing $line so if the command fails, it will show
you the error message. 
Quite useful for debugging purposes. 

Also, there are cases where you may want to process each line of the
returned display, whatever for. 
you can just use an array instead of a string to capture the output : 


my @line = `dir %WINDIR% /AD /B /S`; 
#print @line ;

foreach my $line (@line) { 
        chomp $line ; 
        print "\"$line\"\n" 
        }

This will print a quoted list of the directories in the root of your
%WINDIR% directory
(%SYSTEMROOT% will only work on NT/W2K/XP) 



As others have mentioned, you can't copy directories using 'copy', although
you can 
copy all files in a directory using the syntax  `copy c:\\foo\*.* c:\\foo2` 

But even this may not be that simple. There are other issues you should be
aware of.
If you are using W2k or XP, you'll get a prompt if any existing file is to
be overwritten 
by the copy operation, which will get your process stuck. But you can't use
the /Y 
argument to avoid the prompt because it's unsupported on NT4. 
So you may first need to identify which version of the OS you are using. 
And then again, to make it worse, the arguments may also differ depending on
your OS 
language... Foolproof scripts that rely on system calls and which work on
all windows 
versions are not that easy to make... 

On the other hand, you can use third party tools to perform the copy, but
they have to be 
present on the system first, and you have to ensure that they work
consistently on all 
the different versions of Windows. 

Regards. 

_____________________________________________
Bruno Bellenger
Sr. Network/Systems Administrator 


        -----Original Message-----
        From:   DeAngelo Lampkin [SMTP:[EMAIL PROTECTED]]
        Sent:   Friday, April 19, 2002 7:02 PM
        To:     [EMAIL PROTECTED]
        Subject:        DOS system call nightmares...

        I'm having serious issues making even simple DOS system calls.  

        For example, one system call I want to execute is a function to
copy all the contents (files and subdirectories) of one directory to a
second directory.  Even that won't execute correctly.  I've tried the
following variations:

        (1)`copy c:\\foo\\directory1 c:\\foo\\directory2`; #Normal backticks
operation. "#?" tells me it's getting a bad file descriptor

        (2)system("copy","c:\\foo\\directory1", "c:\\foo\\directory2");
#just in case backslashes are interpolated

        (3)system("copy","c:\foo\directory1", "c:\foo\directory2"); #just in
case backslashes aren't interpolated...yeah, I'm *that* desperate. :)

        (4)system("copy","c:\foo\directory1 c:\foo\directory2"); # I Even
saw this variant in one mailing list archive

        Also, is there a way to to grab the string that's actually being
sent to the system (as opposed to what I *think* is being sent to the
system)?

        Hopefully the problem is something really obvious and if it is, I'll
bang my forehead against the computer 50 times for wasting your valuable
time. 

        Thank you for your help (and patience)!

        DeAngelo Lampkin


          _____  
        
        Send and receive Hotmail on your mobile device: Click Here
<http://g.msn.com/1HM205401/j>
        
        _______________________________________________ ActivePerl mailing
list [EMAIL PROTECTED] To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs 

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to