|
From: mike on 9 Apr 2008 08:42 Hi, I have the following string: my $command = "$User_Preferences{"asadminexecutable"} deploy --user= $User_Preferences{"user"} --passwordfile= $User_Preferences{"passwordfile"} --host=$User_Preferences{"host"} -- port=$User_Preferences{"port"} $User_Preferences{"pathdeployunit"}"; system($command); Global symbol "$command" requires explicit package name at remote_deploy.pl line 55. syntax error at remote_deploy.pl line 55, at EOF Missing right curly or square bracket at remote_deploy.pl line 55, within string Execution of remote_deploy.pl aborted due to compilation errors. Any ideas what I need to do to make it possible to execute the command? cheers, //mike
From: A. Sinan Unur on 9 Apr 2008 09:18 mike <mikaelpetterson(a)hotmail.com> wrote in news:6f8e80dd-1a07-4719-a634- 18f2a21dce0f(a)s37g2000prg.googlegroups.co m: > I have the following string: > > my $command = "$User_Preferences{"asadminexecutable"} deploy > --user= $User_Preferences{"user"} --passwordfile= > $User_Preferences{"passwordfile"} --host=$User_Preferences{"host"} > -- port=$User_Preferences{"port"} > $User_Preferences{"pathdeployunit"}"; system($command); This is a little silly. You do realize that you do not have string, right? You have "$User_Preferences{" followed by the bareword asadminexecutable followed by "} deploy -- ..." etc. > Any ideas what I need to do to make it possible to execute the > command? I would recommend using a LIST argument with system in this case (see perldoc -f system) unless you need some features of the shell: system $User_Preferences{asadminexecutable}, 'deploy', "--user=$User_Preferences{user}", "--passwordfile=$User_Preferences{passwordfile}", "--host=$User_Preferences{host}", "--port=$User_Preferences{port}", "$User_Preferences{pathdeployunit}"; Sinan -- A. Sinan Unur <1usa(a)llenroc.ude.invalid> (remove .invalid and reverse each component for email address) comp.lang.perl.misc guidelines on the WWW: http://www.rehabitation.com/clpmisc/
From: Joost Diepenmaat on 9 Apr 2008 09:21 mike <mikaelpetterson(a)hotmail.com> writes: > Hi, > > I have the following string: > > my $command = "$User_Preferences{"asadminexecutable"} deploy --user= ^^ ^^ ^^ > $User_Preferences{"user"} --passwordfile= ^^ ^^ > $User_Preferences{"passwordfile"} --host=$User_Preferences{"host"} -- ^^ ^^ ^^ ^^ > port=$User_Preferences{"port"} $User_Preferences{"pathdeployunit"}"; ^^ ^^ ^^ ^^^^ get rid of all the double quotes in the $hash{"lookup"} constructs. you don't need them and they break the double quoted string they're interpolated in. -- Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
From: A Dude on 9 Apr 2008 09:48 On Apr 9, 8:42 am, mike <mikaelpetter...(a)hotmail.com> wrote: > Hi, > > I have the following string: > > my $command = "$User_Preferences{"asadminexecutable"} deploy --user= > $User_Preferences{"user"} --passwordfile= > $User_Preferences{"passwordfile"} --host=$User_Preferences{"host"} -- > port=$User_Preferences{"port"} $User_Preferences{"pathdeployunit"}"; > system($command); > > Global symbol "$command" requires explicit package name at > remote_deploy.pl line 55. > syntax error at remote_deploy.pl line 55, at EOF > Missing right curly or square bracket at remote_deploy.pl line 55, > within string > Execution of remote_deploy.pl aborted due to compilation errors. > > Any ideas what I need to do to make it possible to execute the > command? > > cheers, > > //mike Actually, what you have there is a _quoting_ problem. First of all there is no reason to delimit hash keys with the double quotes. But if you're going to do that, you shouldn't surround the whole string literal with double quotes. Use single quotes ( $User_Preferences{'user'} -- if any -- $User_Preferences{user} -- works just fine. ) or surround the thing with the qq operator, to allow for the embedded double quotes. For more on qq: perldoc perlop
From: mike on 9 Apr 2008 09:57
Hi, I changed it to ( taking all pointers into account): my @args = ($User_Preferences{asadminexecutable}, 'deploy', "--user= $User_Preferences{user}","--passwordfile= $User_Preferences{passwordfile}","--host=$User_Preferences{host}","-- port=$User_Preferences{port}","$User_Preferences{pathdeployunit}"); system(@args) == 0 or die "system @args failed: $?" if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; } I get the following error: Possible unintended interpolation of @args in string at remote_deploy.pl line 63. syntax error at remote_deploy.pl line 63, near "system" Global symbol "@args" requires explicit package name at remote_deploy.pl line 63. Global symbol "@args" requires explicit package name at remote_deploy.pl line 63. Execution of remote_deploy.pl aborted due to compilation errors. Does not really help me as a newbie :-) Any ideas? cheers, //mike |