Passing parameters to a system call

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2005
Posts: 3
Reputation: eachowcc is an unknown quantity at this point 
Solved Threads: 0
eachowcc eachowcc is offline Offline
Newbie Poster

Passing parameters to a system call

 
0
  #1
Nov 17th, 2005
Ok. I am trying to write a perl program to automate installation of certain softwares (as root) on a linux machine. I want my perl program to call an installation script and provide parameters to that script such that I do not have to enter 'yes', 'no', 'continue', create directory?', etc, from the command line. I want to fully automate the installation process without much user interaction via keyboard. I need help. Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,052
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Passing parameters to a system call

 
2
  #2
Nov 17th, 2005
Originally Posted by eachowcc
Ok. I am trying to write a perl program to automate installation of certain softwares (as root) on a linux machine. I want my perl program to call an installation script and provide parameters to that script such that I do not have to enter 'yes', 'no', 'continue', create directory?', etc, from the command line. I want to fully automate the installation process without much user interaction via keyboard. I need help. Thanks
To call another program with parameters, you will want to pass a list of parameter strings to the 'system' function.

E.g.
  1. system "cp", "foo", "bar";

See http://www.unix.org.ua/orelly/perl/p...htm#INDEX-5326
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 3
Reputation: eachowcc is an unknown quantity at this point 
Solved Threads: 0
eachowcc eachowcc is offline Offline
Newbie Poster

Re: Passing parameters to a system call

 
0
  #3
Nov 17th, 2005
Originally Posted by Rashakil Fol
To call another program with parameters, you will want to pass a list of parameter strings to the 'system' function.

E.g.
  1. system "cp", "foo", "bar";

See http://www.unix.org.ua/orelly/perl/p...htm#INDEX-5326
Thanks, but what if the program I am calling within my perl script does not take command line arguments? Rather, what if the program I call within my perl script simply outputs a "Create directory?" question where it expects input from the user, rather than a paramter such as "cp foo bar"? I tried echo'ing and piping, and such. Help???
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 178
Reputation: jim mcnamara is on a distinguished road 
Solved Threads: 10
jim mcnamara jim mcnamara is offline Offline
Junior Poster

Re: Passing parameters to a system call

 
0
  #4
Nov 18th, 2005
You need to look at expect rather than trying to use perl.
expect is used for automating interactive dialogues.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 3
Reputation: eachowcc is an unknown quantity at this point 
Solved Threads: 0
eachowcc eachowcc is offline Offline
Newbie Poster

Re: Passing parameters to a system call

 
0
  #5
Nov 18th, 2005
Thanks. It sounds familiar. I will look into it!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Passing parameters to a system call

 
0
  #6
Nov 18th, 2005
Don't be silly. Open the process with a file handle, and you can write data to it that way. For instance:

  1. # /* Open The Program (Just Like A File) Piping Data To It (For Writing) */
  2. open (FH, "| /path2/install/program");
  3.  
  4. # /* Actually Write To The Process */
  5. print FH "Y\n";
  6.  
  7. close(FH);

It will obviously be more complicated than that... but if you change the path and program to your install program, and follow through it step by step, you'll be good to go.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Perl Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC