Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 8th, 2008, 07:45 AM
Member
 
Join Date: Jul 2007
Posts: 34
Default inovking a perl script in a script

Hi,

i have a perl script 123.pl and in that script i am trying to invoke 234.pl which takes one command line argument .is there any way that we can achive the same?
Reply
  #2  
Old August 8th, 2008, 10:36 AM
numberwhun's Avatar
Forum Leader
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,156
Default

What have you tried thus far to do this? Have you looked at the system() function?

Regards,

Jeff
Reply
  #3  
Old August 8th, 2008, 11:09 PM
pawanrpandey's Avatar
Newbie
 
Join Date: Feb 2007
Location: Bangalore
Posts: 11
Default

As suggested by Jeff, you can use 'system' function to call another Perl program from a given program like:
Expand|Select|Wrap|Line Numbers
  1. #-----------------------------------------------------------------------------
  2. # main.pl
  3. # This program calls a second Perl program named 'called.pl' 
  4. # and pass one command line argument
  5. #----------------------------------------------------------------------------
  6. #!/usr/bin/perl -w
  7. use strict;
  8.  
  9. my $passThisArgument = "This is Perl world! \n!" ;
  10. my $cmd = qq@perl /home/pawan/Perl/called.pl $passThisArgument @;
  11. my $result = system($cmd);
  12.  
  13. print "Checking status...: $result \n";
  14. # Do other things...
  15. #---------- End of main.pl------------------------
  16.  
  17. #--------------------------------------------------------------------
  18. # Called.pl
  19. # This Program is called from another program main.pl 
  20. # with a command line argument
  21. #--------------------------------------------------------------------
  22. #!/usr/bin/perl -w
  23. use strict;
  24.  
  25. my $receivedArgument = $ARGV[0];
  26. print " Lets see what parameter was passed to this program...oh! it is: $receivedArgument \n";
  27.  
  28. # All remaining code
  29. #-----END of called.pl----------
Hope this will help you.

Regards,
Pawan
Reply
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles