Unix Technical Forum

Problem in using backtick Operator in Perl

This is a discussion on Problem in using backtick Operator in Perl within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi, I am facing a weired problem with using backtick (` `) opertor in Perl. I am running a ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 07:39 AM
sanjay_up
 
Posts: n/a
Default Problem in using backtick Operator in Perl

Hi,

I am facing a weired problem with using backtick (` `) opertor in Perl.

I am running a java api in shell using perl backtick operator. In my
command i have two options (title and description) whose text have
spaces and newline character. So when run the command with
single/double quotes to give whole text in option i get the No class
defined error.

But when i don't use quotes to club this text then i get API error
(Invalid options ). As API thinks anything after one word as options.

When i run on my shell(ksh) command prompt, it runs fines no error do
it job.
Even in perl without quotes (used for this 2 options) in bactick it
works fine. But i need these 2 options for my porgram,

My perl version is 5.6.0 and aix version 5.1. But i checked on other
Perl and AIX versions and same problem
I have checked all the env variables and they are set fine.

+++++++++++++++

$ENV{CLASSPATH}='/usr/work/ticket/JTicketClient.jar:.';
my $cmd = 'java JTicket.JTicketClient -i TICKET -n process_name -j p'
# for this no error

my $cmd = "java JTicket.JTicketClient -i TICKET -n process_name -j p
-t 'This is title' -d 'This is description' " # for this i am getting
error
$ticket_dir = '/usr/work/ticket'
chdir $ticket_dir;
my $result = `$cmd`;
die "Error Invalid return from Java API - $?:" . Dumper($result) if
( $? != 0);
print "$result\n";
chomp($result);
unless ($result) {
warn "Invalid return from Java API : $result";
return $result;
}

++++++++++
I have tried to use pipe even Safe pipes but no luck.
Can somebody help me.

Also i written this small code to check this is becuase of quotes
++++
#!/usr/bin/perl -w
use Data:umper;
$test = "'Perl is language'";
$res=`echo $test`;
print Dumper(\$res);

on running i am getting extra two new lines

$ perl test.pl


$VAR1 = \'

ram is name
';
~
+++

Tried to used escape sequence but problem presists.

Thanks,
Sanjay

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:00 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com