my $ret = system(executable);
####
perl -e "..."
####
#include "stdio.h"
int main(int argc, char* argv[])
{
int rc,i;
printf("Hello World!\n");
if (argc > 1) {
sscanf(argv[1],"%d",&rc);
printf("Returning with code %d\n",rc);
i = 10/rc;
printf ("i = %d\n",i);
return rc;
}
printf ("Return with code 0\n");
return 0;
}
####
#!/usr/bin/perl
use strict;
use warnings;
my $input = shift || "";
my $cmd = "rcs_c.exe $input";
print "\n\n--- Executing cmd '$cmd' via system\n\n";
my $rc = system $cmd;
print "--- Execution finished with return code: ",$rc>>8,"\n";
print "\n\n--- Executing cmd '$cmd' via backticks\n";
my $return = `$cmd`;
print "--- Execution finished, and returned:\n\n$return\n";
print "\n\nbye...\n";
exit $rc>>8;
####
D:\rcs>perl rcs.pl 0
--- Executing cmd 'rcs_c.exe ' via system
Hello World!
Return with code 0
--- Execution finished with return code: 0
--- Executing cmd 'rcs_c.exe ' via backticks
--- Execution finished, and returned:
Hello World!
Return with code 0
bye...
D:\rcs>perl rcs.pl -1
--- Executing cmd 'rcs_c.exe -1' via system
Hello World!
Returning with code -1
i = -10
Can't spawn "rcs_c.exe -1": No error at rcs.pl line 8.
--- Execution finished with return code: 255
--- Executing cmd 'rcs_c.exe -1' via backticks
--- Execution finished, and returned:
Hello World!
Returning with code -1
i = -10
bye...
D:\rcs>perl -e "system(qq(rcs_c.exe -1))"
Hello World!
Returning with code -1
i = -10
####
my $rc = system ("$cmd");
####
my $rc = system ($cmd);
####
my $rc = system $cmd;