944,120 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 20538
  • Perl RSS
Nov 17th, 2005
0

Passing parameters to a system call

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eachowcc is offline Offline
3 posts
since Nov 2005
Nov 17th, 2005
2

Re: Passing parameters to a system call

Quote 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.
Perl Syntax (Toggle Plain Text)
  1. system "cp", "foo", "bar";

See http://www.unix.org.ua/orelly/perl/p...htm#INDEX-5326
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Nov 17th, 2005
0

Re: Passing parameters to a system call

Quote 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.
Perl Syntax (Toggle Plain Text)
  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???
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eachowcc is offline Offline
3 posts
since Nov 2005
Nov 18th, 2005
0

Re: Passing parameters to a system call

You need to look at expect rather than trying to use perl.
expect is used for automating interactive dialogues.
Reputation Points: 62
Solved Threads: 10
Junior Poster
jim mcnamara is offline Offline
179 posts
since May 2004
Nov 18th, 2005
0

Re: Passing parameters to a system call

Thanks. It sounds familiar. I will look into it!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eachowcc is offline Offline
3 posts
since Nov 2005
Nov 18th, 2005
0

Re: Passing parameters to a system call

Don't be silly. Open the process with a file handle, and you can write data to it that way. For instance:

Perl Syntax (Toggle Plain Text)
  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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: CGI perl SCRIPT
Next Thread in Perl Forum Timeline: Perl/cgi programmer is needed





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC