Passing arguments to commandline with directories having spaces

Posted by superstar on Stack Overflow See other posts from Stack Overflow or by superstar
Published on 2010-04-09T15:12:42Z Indexed on 2010/04/09 15:23 UTC
Read the original article Hit count: 350

Filed under:
|
|

Hi guys, I am making a system call from perl for ContentCheck.pl and passing parameters with directories (having spaces). So I pass them in quotes, but they are not being picked up in the ContentCheck.pl file

Random.pm

my $call = "$perlExe $contentcheck -t $target_path -b $base_path -o $output_path -s $size_threshold";
print "\ncall: ".$call."\n";
system($call);

Contentcheck.pl

    use vars qw($opt_t $opt_b $opt_o $opt_n $opt_s $opt_h);  # initialize
    getopts('t:b:o:n:s:h') or do{ 
    print "*** Error:  Invalid command line option.  Use option -h  for help.\a\n";
    exit 1};

    if ($opt_h) {print $UsagePage; exit; }

    my $tar;
    if ($opt_t) {$tar=$opt_t; print "\ntarget ".$tar."\n";} else {
    print " in target";
    print 
     "*** Error:  Invalid command line option.  Use option -h  for help.\a\n";
    exit 1;}
    my $base;
    if ($opt_b) {$base=$opt_b;} else {
    print "\nin base\n";
    print "*** Error:  Invalid command line option.  Use option -h  for help.\a\n";
    exit 1;}

This is the output in the commandline

call: D:\tools\PacketCreationTool/bin/perl/winx64/bin/perl.exe D:/tools/PacketCr
eationTool/scripts/ContentCheck.pl -t "C:/Documents and Settings/pkkonath/Deskto
p/saved/myMockName.TGZ" -b "input file/myMockName.TGZ" -o myMockName.validate -s
 10

target C:/Documents

in base
*** Error:  Invalid command line option.  Use option -h  for help.

Any suggestions are welcome! Thanks.

© Stack Overflow or respective owner

Related posts about command

Related posts about line