Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone know what changed in Perl 5.8 regarding command execution? 2

Status
Not open for further replies.

wardy66

Programmer
Jun 18, 2002
102
AU
Hi all.

I have written a script that runs another Perl script via:

Code:
open CMD, "$command |";

$command will equal, e.g., (with the double quotes)

Code:
"perl" "C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl"

Running under Perl 5.8 it works fine. Perl 5.6 throws "No such file or directory"

Anyone know what might have changed on the open command that's affecting me?

Thanks in advance
~ Michael
 
Shouldn't that be:

Code:
$command = "perl C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl"

anyways, print the value of $command to the screen so you can see what the value is before running it in the open function.

- Kevin, perl coder unexceptional!
 
perhaps the path to perl is required as well? especially if called under a webserver's environment

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
You can get all the differences between 5.6 and 5.8 by typing "perldoc perl58delta" on your command line.
 
Thanks, Kevin

The command value was the one I pasted in in my original post.

The reason I had "perl" "script" was that the path to Perl can be specified in the script too, possibly with spaces too. The -P option does this, as this example shows.

Code:
c:\perl560\bin\perl wow-wrapper.pl -c symdg-detail -P c:\perl560\bin

The error I get is this, which is from the command:
Code:
open CMD, "$command |";
if ( $OS_ERROR ) {
    print {$LOG} "$msg_prefix\tERROR: Attempt to run command $command failed with $OS_ERROR\n";
    die "ERROR: $command: $OS_ERROR\n";
}

ERROR: "C:\perl560\bin\perl" "C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl": No such file or directory

Ishnid - thanks for the perldoc. I didn't know about that one but it'll take me a while to digest :)
 
forward slashes, or \\ instead of \ might do the trick

HTH


Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Excellent suggestions, thanks Paul

But no difference :-(

"C:\\perl560\\bin\\perl" "C:\\Documents and Settings\\wardmm\\My Documents\\cygwin\\home\\wardmm\\perl\\symdg-detail.pl": No such file or directory

"C:/perl560/bin/perl" "C:/Documents and Settings/wardmm/My Documents/cygwin/home/wardmm/perl/symdg-detail.pl": No such file or directory
 
Code:
if (-f "C:/perl560/bin/perl.exe" && -f "C:/Documents and Settings/wardmm/My Documents/cygwin/home/wardmm/perl/symdg-detail.pl") {
   print "both files exist\n";
}
else {
   print "one of the files doesn't exist\n";
}

-------------
Kirsle.net | Kirsle's Programs and Projects
 
Thanks Kirsle - good suggestion.

I inserted this code:

Code:
if (-x $PERL) {
    print "perl ($PERL) exists and is executable\n"
}
else {
    print "exec perl ($PERL) can't be found\n"
}
if (-f $full_command) {
    print "command ($full_command) exists\n"
}
else {
    print "can't find command ($full_command)\n"
}

Later, I put together the two components (Perl and command)
Code:
my $command = '"' . $PERL . '" "' . $full_command . '"';
print "Running command $command\n" if $VERBOSE;

And then run it:
Code:
open CMD, "$command |";
if ( $OS_ERROR ) {
    print {$LOG} "$msg_prefix\tERROR: Attempt to run command $command failed with $OS_ERROR\n";
    die "ERROR: $command: $OS_ERROR\n";
}

Here's the output:

[tt]
perl (C:\perl560\bin\perl.exe) exists and is executable
command (C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl) exists
Running command "C:\perl560\bin\perl.exe" "C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl"
ERROR: "C:\perl560\bin\perl.exe" "C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl": No such file or directory
[/tt]

Very perplexing. It seems to be able to find both the Perl executable and the Perl script but has trouble running it. As I said before, 5.8 handles it fine.

Thanks again.
 
Solved :)
Thanks to all that chimed in.

It seems that Perl 5.6 is not tolerant of the double quotes for an executable.

[tt]
perl (C:\perl560\bin\perl.exe) exists and is executable
command (C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl) exists
Running command C:\perl560\bin\perl.exe "C:\Documents and Settings\wardmm\My Documents\cygwin\home\wardmm\perl\symdg-detail.pl"
[/tt]

This works under both 5.6 and 5.8 so as long as Perl is in a path without spaces, I think I'll be right .... [bigglasses]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top