RayRay459 has asked for the wisdom of the Perl Monks concerning the following question:

I have this block of code that i am running.
open(LIST,$List) or die "Can't read $List: $!"; while (<LIST>) { chomp(my $Server = $_); my $source1 = "C:/ChPass/phrase.txt"; my $dest1 = "//$Server/c\$/temp/phrase.txt"; print $dest1; my $command = qq(copy "$source1" "$dest1") or die "Couldn't copy $ +source1: $!"; $command =~ s#/#\\#g; system $command; print " I finished the first command.\n"; my $source2 = "C:/ChPass/ChPass.exe"; my $dest2 = "//$Server/c\$/temp/ChPass.exe"; my $command2 = qq(copy "$source2" "$dest2") or die "Couldn't c +opy $source2: $!"; $command2 =~ s#/#\\#g; print $command2; system $command2; print " I finished the second command.\n"; print $Server . "\n";

I am then calling on the exe that i copied over which is a compiled perl script. It is waiting for a server name and a caridge return. so i put $Server after the chpass.exe but i need a way to put in a caridge return so that it can see the server name.
system("//$Server/c\$/temp/ChPass.exe $Server"); print " I called the executable and it completed.\n"; }

Can someone tell me how i can simulate me hitting enter after the exe sees the server name. Thanks in advance.
Ray

Replies are listed 'Best First'.
(tye)Re2: my compiled perl script is waiting for input
by tye (Sage) on Aug 23, 2001 at 22:56 UTC
    system("//$Server/c\$/temp/ChPass.exe $Server");

    You are putting the server name on the command line which the script would see in @ARGV but the script is trying to read (from STDIN?), so you want something more like: system("echo $Server | //$Server/c\$/temp/ChPass.exe"); just to give one example of a way to do it.

    Note, however, that running "//$Server/..." just copies the script from that server and runs it on the local computer! To have the script actually run on a remote computer requires more than just file sharing. See Using WMI for create a remote Process on Win32 for one example of how to do that.

            - tye (but my friends call me "Tye")
Re: my compiled perl script is waiting for input
by dws (Chancellor) on Aug 23, 2001 at 22:39 UTC
    The statement   my $command = qq(copy "$source1" "$dest1") or die "Couldn't copy $source1: $!"; isn't doing what you appear to think it is. Try qx() instead of qq()

      qx() won't do what he wants either. He just needs to move the "or die" part down a few lines so that it is after the call to system and change it to "and die" since system is about the only Perl routine that return a false value for success.

              - tye (but my friends call me "Tye")
Re: my compiled perl script is waiting for input
by RayRay459 (Pilgrim) on Aug 23, 2001 at 23:14 UTC
    Thanks guys for all your help. It is very much appreciated. Ray