I feel like I'm missing something pretty obvious here, but I can't figure out what's going on. I have a perl script that I am calling from C code. The script + arguments look something like this:
my_script "/some/file/path" "arg" "arg with spaces" "arg" "/some/other/file"
When I run it on Windows, Perl correctly identifies it as 5 arguments, whereas when I ran it on a SunOS Unix machine, it identified 8, breaking arg with spaces into separate arguments.
Not sure if this matters, but on Windows I run it as:
perl my_script <args>
While on Unix, I run it as an executable, for example, above.
Any idea why Unix is mismanaging this argument?
Edit:
Here is the code to call the perl script:
char cmd[1000];
char *script = "my_script";
char *argument = "\"arg1\" \"arg2\" \"arg3 with spaces\" \"arg4\" \"arg5\"";
sprintf( cmd, "%s %s >1 /dev/null 2>&1", script, arguments);
system( cmd );
This is not entirely true, as I am building the argument string a bit dynamically, but that is the point.
, :
($arg1, $arg2, $arg3, $arg4, $arg5) = @ARGV;
, , script C, .