I want to write a script foo which simply calls bar with the exact same arguments it was called with, using Bash or Perl.
Now, a simply way to do this in perl would be
#!/bin/perl
my $args=join(' ', @ARGV);
`bar $args`;
However, the values in ARGV have already been processed by the shell, thus if I call
foo "I wonder, \"does this work\""
bar would get called like this
bar I wonder "does this work"
How can I obtain the original command line so that I can simply pass it on verbatim?
system()is the return value from the execution of the program, not the output from the program. It may be necessary to redirect output to a file and read the file, if you're trying to collect its output. – atk Nov 19 '09 at 19:13