Rsync options not recognized by system function
Rsync options not recognized by system function
am 27.05.2011 21:10:01 von Ezra Taylor
--bcaec51dd5c7008c9304a446b1ca
Content-Type: text/plain; charset=ISO-8859-1
Hello All:
My rsync options are not being recognized in the system
function. I tried escaping the asterisks and single quotes to no avail.
Also, I do not want to install any rsync modules. Your help will be much
appreciated. Thanks.
my $RSYNC_OPTS=' -auvr --include='*/' --exclude='*' ';
my $RSYNC="/usr/bin/rsync";
system("$RSYNC", "$RSYNC_OPTS", "$host:/Blah/blah/Blue/$host_env/$cluster",
"/tmp/$host");
--
Ezra Taylor
--bcaec51dd5c7008c9304a446b1ca--
Re: Rsync options not recognized by system function
am 27.05.2011 21:58:07 von Kenneth Wolcott
On Fri, May 27, 2011 at 12:10, Ezra Taylor wrote:
> Hello All:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0My rsync options are not being recognized =
in the system
> function. =A0I tried escaping the asterisks and single quotes to no avail=
..
> Also, I do not want to install any rsync modules. =A0Your help will be mu=
ch
> appreciated. =A0 Thanks.
>
>
> my $RSYNC_OPTS=3D' -auvr --include=3D'*/' --exclude=3D'*' ';
> my $RSYNC=3D"/usr/bin/rsync";
>
>
>
>
> system("$RSYNC", "$RSYNC_OPTS", =A0"$host:/Blah/blah/Blue/$host_env/$clus=
ter",
> "/tmp/$host");
Try single quotes for the strings that contain shell wildcards such as aste=
risk.
Ken Wolcott
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Rsync options not recognized by system function
am 27.05.2011 22:13:16 von Uri Guttman
>>>>> "ET" == Ezra Taylor writes:
ET> Hello All:
ET> My rsync options are not being recognized in the system
ET> function. I tried escaping the asterisks and single quotes to no avail.
ET> Also, I do not want to install any rsync modules. Your help will be much
ET> appreciated. Thanks.
ET> my $RSYNC_OPTS=' -auvr --include='*/' --exclude='*' ';
that isn't valid perl. is that the actual line you used? you can't put
single quotes inside a string delimited with single quotes. the best way
is to use the q operator and choose a different delimiter. also use
white space around the =.
my $RSYNC_OPTS = q{ -auvr --include='*/' --exclude='*' } ;
ET> system("$RSYNC", "$RSYNC_OPTS", "$host:/Blah/blah/Blue/$host_env/$cluster","/tmp/$host");
there is not need to quote scalar vars like that. in fact it could lead
to a bug in some situations.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Rsync options not recognized by system function
am 27.05.2011 23:10:16 von jwkrahn
Uri Guttman wrote:
>>>>>> "ET" == Ezra Taylor writes:
>
> ET> Hello All:
> ET> My rsync options are not being recognized in the system
> ET> function. I tried escaping the asterisks and single quotes to no avail.
> ET> Also, I do not want to install any rsync modules. Your help will be much
> ET> appreciated. Thanks.
>
>
> ET> my $RSYNC_OPTS=' -auvr --include='*/' --exclude='*' ';
>
> that isn't valid perl. is that the actual line you used? you can't put
> single quotes inside a string delimited with single quotes. the best way
> is to use the q operator and choose a different delimiter. also use
> white space around the =.
>
> my $RSYNC_OPTS = q{ -auvr --include='*/' --exclude='*' } ;
>
> ET> system("$RSYNC", "$RSYNC_OPTS", "$host:/Blah/blah/Blue/$host_env/$cluster","/tmp/$host");
>
> there is not need to quote scalar vars like that. in fact it could lead
> to a bug in some situations.
The real problem is that $RSYNC_OPTS contains whitespace and you can't
mix system(LIST) and system(STRING) together like that. It has to be
either:
system($RSYNC, split( ' ', $RSYNC_OPTS ),
"$host:/Blah/blah/Blue/$host_env/$cluster", "/tmp/$host");
Or:
system("$RSYNC $RSYNC_OPTS $host:/Blah/blah/Blue/$host_env/$cluster
/tmp/$host");
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: Rsync options not recognized by system function
am 31.05.2011 12:03:15 von Chris Nehren
On Fri, May 27, 2011 at 14:10:16 -0700 , John W. Krahn wrote:
>
> The real problem is that $RSYNC_OPTS contains whitespace and you
> can't mix system(LIST) and system(STRING) together like that. It has
> to be either:
>
> system($RSYNC, split( ' ', $RSYNC_OPTS ),
> "$host:/Blah/blah/Blue/$host_env/$cluster", "/tmp/$host");
>
> Or:
>
> system("$RSYNC $RSYNC_OPTS $host:/Blah/blah/Blue/$host_env/$cluster
> /tmp/$host");
Note that the LIST form of system won't have problems with shell
variables, so is generally a better idea unless the shell variable
interpolation behavior is desired.
--
Chris Nehren | Coder, Sysadmin, Masochist
Shadowcat Systems Ltd. | http://shadowcat.co.uk/
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/