Hello, I'm trying to pass values from parent process to child without success. I'm using system().Following the parent process "sms.pl" end the child process "sms_decry.pl"
#!/usr/bin/perl ######################### # Call packages ######################### use strict; use warnings; use Device::Gsm; ########################## #Declaration of global variables ########################## #Variable gsm my $gsm; #Array of messages my @msg; #Dimension of array my $taille; #Get the answer yes or no from keyboard my $answer; #Name of modem my $name; #Model of modem my $model; #imei of modem my $imei; # last number received my $dernier_num; # last message received my $dernier_msg; ########################## # Main ########################## read_sms(); connect_soekris(); ########################################### #Connect soekris ########################################### sub connect_soekris{ # creat local array to handle the nmbr of sms in the card my @tab=($taille); print"\nSouhaitez vous rentrez en contact avec un routeur soekris? +(yes/no) "; $answer = <STDIN>; chomp($answer); if ($answer =~ /yes/ ) { my $a =0; while(1) { # read SMS of Sim card my @msg2=$gsm->messages('SM'); # get the number of sms in the card my $taille2 = @msg2; if ($taille2 == 9) { print "supression automatique des sms !! \n"; $gsm->delete_sms(0,'SM'); $gsm->delete_sms(1,'SM'); $gsm->delete_sms(2,'SM'); $gsm->delete_sms(3,'SM'); $gsm->delete_sms(4,'SM'); $gsm->delete_sms(5,'SM'); @msg2 = $gsm->messages('SM'); $taille2 = @msg2; } #Stockthe number of sms in @tab push (@tab,$taille2); # if new message is received if($tab[-1] != $tab[-2] ) { # get the number of the last sender my $dernier_num = $msg2[$#msg2]->sender(); # get the sms of the last sender my $dernier_msg = $msg2[$#msg2]->content(); # Enlever le retour chariot #chop($dernier_msg); print "Vous avez recu un nouveau message!!\n$dernier_n +um : $dernier_msg"; if ( $dernier_msg eq "coucou") { my $adr="/home/hajar_folder/perl_script/2013/sms_d +ecry.pl"; system("perl",$adr); #exit; $a=1; #$newtime = (time+40); } else { print "\nAucune reponse n'a ete envoyee a votre in +terlocuteur!!\n"; $a=0; #$newtime = (time+40); } } } } }
#!/usr/bin/perl ######################### # Call packages ######################### use strict; use warnings; use Device::Gsm; ########################## # Main ########################## decry_sms(); ################## sub decry_sms(){ print"I'm in decry_sms script\n"; print" $dernier_num \n"; }

In reply to pass values frrom parent process to child by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.