Hi Sooraj, On Thursday 23 September 2010 18:42:17 Sooraj S wrote: > Hi, > > In my perl script p1 i am calling another script p2 which logs into a > remote machine and executes a script p3.
Generally speaking, executing one perl script you've written from another perl script is an indication that you're doing something wrong. Please consider extracting the relevant functionality into a module and loading it from one or both scripts and invoking its functions or object methods. For introductions to modules (.pm files) see: 1. http://perl-begin.org/tutorials/perl-for-newbies/part3/ 2. http://www.perl.org/books/beginning-perl/ > The $file defined in p3 does > not exist. What do you mean by not exist? And you shouldn't call a variable $file, because it is too ambiguous . > So copy operation in p3 will error out with error code 256 > and p3 stops execution with exit staus 256. But p2 is not able to > recieve this value. Did you try looking at the shell's "$?" variable? > I need the value 256 in p2. Could any one help me > to sove this.. > > p1 > === > ........ > ........ > system(p2 $opt); > if ($? == 0) { print "success"; } > elsif ($? == 1) { print "failure"; } > else { print "Undefined exit status"; } > ........ > ........ Please see: http://perl-begin.org/tutorials/bad-elements/ for how to write these codes properly. > > p2 > === > use Net::Telnet; > > $t = new Net::Telnet(); > $t->open("machine"); > $t->login("user","paswd"); > $t->cmd("p3 $flag"); Here you need to check the value of the shells $? variable. > $t->close(); > > print "Check : $?"; // prints $? value as > 0; > if ($? == 0) { exit(0); } > elsif ($? == 1) { exit(1); } > else { exit($?); } > > > p3 > === > my $file = "/hom/user/file"; > ..... > ...... > system(cp -rf $file $backup); > unless($? ==0) > { > print "Failed to create the back up with exit_status $?"; // > prints $? value as 256. > exit($?); > } > ..... > .... Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Best Introductory Programming Language - http://shlom.in/intro-lang <rindolf> She's a hot chick. But she smokes. <go|dfish> She can smoke as long as she's smokin'. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/