0

I am logged to a system in /bin/bash, as a regular user, then I need run a perl script which in turns starts a ksh shell. After the perl script is done both shells are alive (bash and ksh) How can i write a script which will be triggered from bash, then it will launch the perl script, and subsequent commands need to be run in the new launched ksh.. as of now commands writen after the perl script hang.. and are run until I exit ksh.. I am able to see both SHELLs PID but do not know how to run a commands in the second one while script is run in the first one..

example:

#!/bin/bash
pathtoperl=/path/to/perl/script

command1
command2
##call perl command which initiates a ksh among other stuff
$pathtoperl/perlscript -arguments

command3     #need to be run in new ksh, not in current /bin/bash
command4     #need to be run in new ksh, not in current /bin/bash
  • You'll probably want to use a server:client model: the ksh shell can listen to a port where you can send commands, and the shell can eval them. – glenn jackman Feb 16 '17 at 14:42
0

IF you are the parent or sibling process, you can keep a reference to stdin of the ksh process and send commands that way, but generally, you can't send commands to a random running process in this way. So in your example, you could use the perl script to send commands to the ksh on stdin. But your login bash script doesn't know about the running ksh after the perl script exits.

  • The perl script is maintained by different team, and shared on the same server. I would rather to be able to execute command3 and 4 from outside of perl script. – Miguel Gomez Glez Feb 15 '17 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.