Interactive shell from system()?

B

bh_ent

Hi all,

After reading the documentation for "system()" I understand perl
launches the arguments via "sh -c" or whatever my system equivalent is.

I've written a series of ksh scripts I'd like to launch from my perl
script, but the ksh scripts are interactive (ie, prompts the user, and
reads their input), however, this obviously doesn't work via system()
from within my perl script.
Any suggestions how I might accomplish this?
 
P

Paul Lalli

After reading the documentation for "system()" I understand perl
launches the arguments via "sh -c" or whatever my system equivalent is.

I've written a series of ksh scripts I'd like to launch from my perl
script, but the ksh scripts are interactive (ie, prompts the user, and
reads their input), however, this obviously doesn't work via system()
from within my perl script.
Any suggestions how I might accomplish this?

system() is not suitable to your task.

Check out Expect or Expect::Simple, both available from
http://search.cpan.org

Paul Lalli
 
B

Big and Blue

I've written a series of ksh scripts I'd like to launch from my perl
script, but the ksh scripts are interactive (ie, prompts the user, and
reads their input), however, this obviously doesn't work via system()

I'm not sure what is "obvious" about this - particularly given that
it works.

e.g., this script:

===== z.sh =====
#!/bin/sh

while echo -n '>> ' && read line; do
echo "Just got: $line"
done
echo
=====

and this perl command:

system("./z.sh");

works perfectly and interactively for me.
 

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,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top