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

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.

system "cp", "foo", "bar";

See http://www.unix.org.ua/orelly/perl/prog3/ch29_02.htm#INDEX-5326

To call another program with parameters, you will want to pass a list of parameter strings to the 'system' function.

E.g.

system "cp", "foo", "bar";

See http://www.unix.org.ua/orelly/perl/prog3/ch29_02.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???

You need to look at expect rather than trying to use perl.
expect is used for automating interactive dialogues.

Thanks. It sounds familiar. I will look into it!

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

# /* Open The Program (Just Like A File) Piping Data To It (For Writing) */
open (FH, "| /path2/install/program");

     # /* Actually Write To The Process */
     print FH "Y\n";

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.