Re: cant process string in system()
- From: chas.owens@xxxxxxxxx (Chas Owens)
- Date: Mon, 27 Feb 2006 09:16:22 -0500
On 2/27/06, Brent Clark <bclark@xxxxxxxxxxxxxxx> wrote:
snip
Basically what happening is, when I pass the variable to system() thespaces are not escaped etc, and therefore fetchmail
only processing only half the string.most grateful
If anyone knows how I can achieve in processing the string as is, would be
snip
There are two methods of calling system that should solve your problem:
use the system shell and surround the arguments with quotes
system(qq(fetchmail -f "$fetchmailconf" -a -k -r "$folderitem"));
and avoid using the shell altogether
system('fetchmail', '-f', $fetchmailconf, '-a', '-k', '-r', $folderitem);
It looks like you were trying to do the first an got confused by the
behaviour of single quote strings.
The string ' -a -k -r \"' is stored as the literal [-][a][ ][-][k][ ]-[r][
][\]["]. This is becuase single quote strings do not handle
interpolation. Here is the relevant section of the perlop* documentation:
Customary Generic Meaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
For constructs that do interpolation, variables beginning with "$"
or "@" are interpolated, as are the following sequences. Within a
transliteration, the first ten of these sequences may be used.
\t tab (HT, TAB)
\n newline (NL)
\r return (CR)
\f form feed (FF)
\b backspace (BS)
\a alarm (bell) (BEL)
\e escape (ESC)
\033 octal char (ESC)
\x1b hex char (ESC)
\c[ control char
\l lowercase next char
\u uppercase next char
\L lowercase till \E
\U uppercase till \E
\E end case modification
\Q quote non-word characters till \E
* you can read the rest of the perlop documentation by typing "perldoc
perlop" or "man perlop" on your command line or by going to
http://perldoc.perl.org/perlop.html
- References:
- cant process string in system()
- From: Brent Clark
- cant process string in system()
- Prev by Date: Re: survive with exec
- Next by Date: error messege: "subroutine Cwd::fastcwd redefined"
- Previous by thread: cant process string in system()
- Next by thread: survive with exec
- Index(es):
Relevant Pages
|
|