Re: problem using system()



On Apr 9, 8:42 am, mike <mikaelpetter...@xxxxxxxxxxx> 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
.



Relevant Pages

  • Re: runas: need help with those quotes
    ... matters, both paths have spaces, so they are enclosed in quotes. ... 'This command echos the the strCmd to the screen. ... Quotes embedded in a quoted string should be doubled. ...
    (microsoft.public.scripting.vbscript)
  • Re: runas: need help with those quotes
    ... matters, both paths have spaces, so they are enclosed in quotes. ... 'This command echos the the strCmd to the screen. ... Quotes embedded in a quoted string should be doubled. ...
    (microsoft.public.scripting.vbscript)
  • Parsing a bash string?
    ... For my application, which is a wrapper over bash, ... I have to be able to parse a command line typed by the user. ... I.e., I need a function that, when given a typical bash command string like ... I have to remove the quotes (notice the last ...
    (comp.unix.shell)
  • Re: XP SP2 command line trouble - update
    ... If the OS is wrapping the path in quotes ... de-quote the strings, which would just need a function you pass any string ... unquote = replace$, "") ... command line itself, on at least this particular XP SP2 ...
    (microsoft.public.vb.general.discussion)
  • Re: running vbscript syntax error
    ... A string must be passed to the Run method. ... The double quotes in the string are resolved to single quotes. ... To troubleshoot, run a script where you define the value of strCmd as above, ... is a syntax error, perhaps due to unbalanced quotes, you can fix it. ...
    (microsoft.public.scripting.vbscript)