[Memphis.pm] quotes in program arguments
Hal Phillips
HPhillips at harrahs.com
Tue Nov 12 10:23:52 CST 2002
Hey, does anyone know how to tell perl to interpret quotes in a program
argument as just part of a string? More precicely, I need something that
basically will take the equivalant of echo's $* as a command argument.
What I neet to do is have a perl program that I can to this with:
>program.pl -o [2002-11-12 09:00:00]: subject=SOMETEXT,
message={SEVERITY="ERROR", ACTION="None", MOREKEYS="MOREVALUES", ETC="ETC
ETC ETC"}
You may ask, why not just redirect the message as STDIN? Well, the calling
program is very limited in it's interface in that it collects the message
information into a variable via java, then provides an opportunity for you
to fill in a box with a UNIX command. So, I'd need to somehow push it into
STDIN through a pipe, and echo is out for the same reasons I'm trying to
solve with the quotes in $message.
i.e. echo $message | program.pl doesn't work because of the content of
$message.
So, I need it to do:
program.pl -o $message
I've tried to be sneaky and read in the option a char at at time, but the
quotes are still being interpreted on the command line.
#!/usr/bin/perl
use Getopt::Std;
getopt("o:");
@array = split (//, $opt_o);
foreach $char (@array)
{
if ( $char eq "\"" )
{
$char = "\\$char";
}
$message .= $char;
}
print $message;
> program.pl -o Sam"I"am
SamIam
what I need is Sam"I"am to actually make it through uninterpreted.
Anyway, sorry to ramble, let me know if you have any suggestions.
-Hal
----------------------------------------------------------------------------
To unsubscribe, please send email to majordomo at pm.org
with 'unsubscribe memphis-pm-list' in the body of the message.
----------------------------------------------------------------------------
More information about the Memphis-pm
mailing list