automate command line script using perl

P

perlperl

i have a bash script,
when i run this script, its a interactive script and ask users couple
of questions and move forward and completes the script.

is there a way i can automate that using perl, if i know the sequence
of questions and the answer i need to provide.
 
J

Jürgen Exner

perlperl said:
i have a bash script,
when i run this script, its a interactive script and ask users couple
of questions and move forward and completes the script.

is there a way i can automate that using perl, if i know the sequence
of questions and the answer i need to provide.

You may want to check out the Expect module.

jue
 
P

perlperl

just to make sure what i am looking,
when i run the bash script,
it ask me
"would you like to install thi Y/N?"

would you like to install this y/n?

and so on....
i want to automate all this stuff (assuming i know all the answers in
advance)
also i just saw bash script, its a test.csh script (c-shell script)

Do you mein "use Expect" of Perl?
 
P

perlperl

Example)
how can i automate this script using perl

#!/usr/bin/csh

echo "Would you like o continue [y/n]?"
set test = $<
if ($test == "y") then
echo "How many time do you want to run the script: ?"
set times = $<
echo "You enters $times "
else
echo "Exit"
endif
 
T

Tad McClellan

perlperl said:
Do you mein "use Expect" of Perl?


Does who mean what?

Please quote some context in your followups like everybody else does.

There is not "Expect of Perl", but there is an "Expect module" for Perl:

http://search.cpan.org/~rgiersig/Expect-1.17/


See also:

perldoc -q module

What modules and extensions are available for Perl? What is CPAN?
What does CPAN/src/... mean?

How do I find which modules are installed on my system?

How do I create a module?

How do I install a module from CPAN?

How do I keep my own module/library directory?
 
T

Tintin

perlperl said:
i have a bash script,
when i run this script, its a interactive script and ask users couple
of questions and move forward and completes the script.

is there a way i can automate that using perl, if i know the sequence
of questions and the answer i need to provide.


If you have simple questions that are predictable, you can simple pipe or
redirect the answers, eg:

echo "yes\nno" | /path/to/script

or create a file with the responses, eg:

$ cat responses
yes
no

$ /path/to/script <responses
 
P

perlperl

i installed expect-5.43 and tcl8.5a4 and saved both in C:
if i try to run autoexpect, i get autoexpect is not recognized internal
or external command
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top