Bring prompt from a different process

Hi,

while running a program one of the command is creating a sub-shell which requires user inputs. Is there a way to bring the input prompt to a parallel session or an alternate way to input the values? the outer program doesn't allow to accept the parameter value for the command run in the sub shell.

Thanks!!

There is no reason why a process running in a subshell can't read user input. But, a process running in the background can't. Only a foreground process can read from the controlling terminal for that process group.

Hi Don,

It is indeed a foreground process which is being created be a program as another user which I need to bring it on to a prompt to be able to input the values. is there a way to bring the input prompt from a process that is already waiting for a process from one session to another?

Thanks,
Waseem

I don't understand what you mean by bringing a process on to a prompt.

Maybe a concrete example showing what processes are running, what user IDs and group IDs were used when invoking those utilities, what prompts those processes are writing, and what input they are trying to read would help.

sure. I am running a setup program as root. This starts a web GUI to get user inputs. Using the input user name from the webpage it starts a command as su.

1. setup command holds the screen and starts web interface(root) 
>> 2. In Web interface it asks for user name input
>> 3. Using user name input provided in the web page a new sh script(generated on fly) is executed which runs java command
>>4 this java command requires input from humans and it holds the processes and hangs forever.  

I hope this provides the clarification!!

I'm lost as well.

If you are running a script in a terminal emulator like xterm or lxterminal , you could open another terminal running your second program in parallel:

su -c "lxterminal -e ./yourscript"  newuser

---------- Post updated at 12:28 ---------- Previous update was at 12:24 ----------

Be aware that there are no automatically created data/information exchange channels between the processes. You'd need to use fifos or files.

Ok, let me try to clarify again. Sorry for the confusion.

Here is a sample code

./wrapper.sh

within wrapper.sh


runuser -l username -c read -p "input a value" input

In the above example wrapper.sh is being triggered as root which in turn is running read command as another user waiting for input. can I have a parallel session logged in as "username" and get to input?

And you want the result back in the original session?

Either the original session or a new parallel session