Click here to get back home

problem using system()

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
problem using system() mike 04-09-2008
Get Chitika Premium
Posted by mike on April 9, 2008, 8:42 am
Please log in for more thread options
Hi,

I have the following string:

my $command = "$User_Preferences deploy --user=
$User_Preferences --passwordfile=
$User_Preferences --host=$User_Preferences --
port=$User_Preferences $User_Preferences";
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

Posted by A. Sinan Unur on April 9, 2008, 9:18 am
Please log in for more thread options
news:6f8e80dd-1a07-4719-a634-
18f2a21dce0f@s37g2000prg.googlegroups.co
m:

> I have the following string:
>
> my $command = "$User_Preferences deploy
> --user= $User_Preferences --passwordfile=
> $User_Preferences --host=$User_Preferences
> -- port=$User_Preferences
> $User_Preferences"; 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,
'deploy',
        "--user=$User_Preferences",
        "--passwordfile=$User_Preferences",
"--host=$User_Preferences",
"--port=$User_Preferences",
"$User_Preferences";

Sinan

--
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

Posted by Joost Diepenmaat on April 9, 2008, 9:21 am
Please log in for more thread options

> Hi,
>
> I have the following string:
>
> my $command = "$User_Preferences deploy --user=
^^ ^^ ^^

> $User_Preferences --passwordfile=
^^ ^^
> $User_Preferences --host=$User_Preferences --
^^ ^^ ^^ ^^
> port=$User_Preferences $User_Preferences";
^^ ^^ ^^ ^^^^

get rid of all the double quotes in the $hash 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/

Posted by mike on April 9, 2008, 9:57 am
Please log in for more thread options
Hi,

I changed it to ( taking all pointers into account):


my @args = ($User_Preferences, 'deploy', "--user=
$User_Preferences","--passwordfile=
$User_Preferences","--host=$User_Preferences","--
port=$User_Preferences","$User_Preferences");

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

Posted by Japhio on April 9, 2008, 10:21 am
Please log in for more thread options
> Hi,
>
> I changed it to ( taking all pointers into account):
>
> my @args = ($User_Preferences, 'deploy', "--user=
> $User_Preferences","--passwordfile=
> $User_Preferences","--host=$User_Preferences","--
> port=$User_Preferences","$User_Preferences");
>
> system(@args) == 0 or die "system @args failed: $?"

[cut]

> Possible unintended interpolation of @args in string at
> remote_deploy.pl line 63.
> syntax error at remote_deploy.pl line 63, near "system"

^^^ Here is the nasty bit!

> 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.
>

There is a semicolon ';' missing after the line with system().

By the way, from the error message 'Global symbol "@args" requires
explicit package name' I infer that you use the strict pragma, which
is a good thing. Now learn to interpret the error messages ;-)

> Does not really help me as a newbie :-)
> Any ideas?

Keep on trying!

Similar ThreadsPosted
system problem May 16, 2005, 8:35 pm
problem with system(@args) February 18, 2005, 7:52 am
Python Doc Problem Example: os.system September 4, 2005, 5:16 pm
problem with system() and fork November 7, 2005, 6:47 am
SYSTEM command problem April 20, 2006, 10:01 am
Problem with system command February 8, 2007, 12:36 pm
Problem with Perl system() December 18, 2007, 8:13 am
Re: Problem with call to system(), I think. December 3, 2008, 5:53 pm
Problem with cp in system call running Mac OS X November 7, 2004, 10:50 am
system call problem under Win32 May 31, 2006, 11:51 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap