can a nohup'ed ksh script interact with user


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting can a nohup'ed ksh script interact with user
# 1  
Old 05-29-2012
can a nohup'ed ksh script interact with user

I have a long running ksh script that I need to run with "nohup" in the backgound which is all well and good but at the very start of the script it needes to output to the screen to query the user and accept a response before continuing.

Any thoughts on how to accomplish this other than breaking the script into two scripts where the first one queries the user and based on the input executes the second script with nohup in background? Basically I would preferr to have a self contained script.

Thanks...
# 2  
Old 05-29-2012
Probably the most effective way to do this would be to run it in GNU Screen. This would give it its own virtual terminal that you could talk to it with at will.

I'm not sure nohup would be necessary anymore if you plunked it in a screen session, either.
# 3  
Old 05-29-2012
Quote:
with "nohup" in the backgound
Do you mean:
Code:
nohup scriptname &

Any reason to not present the script with the parameter(s) on the command line?
Code:
nohup scriptname parameter &

# 4  
Old 05-29-2012
I'm working in Solaris 10 and there is no GNU software on the system or at least none that I can find, but thanks for the idea as I've not heard of that before and it does sound useful.
# 5  
Old 05-29-2012
I'm not sure what other way you could do this. If you put the script in the background, it loses the ability to read from the terminal. It can still write to it by opening /dev/tty, but it doesn't control the terminal, hence can't read from it... Just tried this out to be sure.
# 6  
Old 05-29-2012
Not to mention that the output for the user is "lost" in nohup.out even if it's FG script. I guess I will have to break the script into two parts in separate files.

Thanks...

---------- Post updated at 12:36 PM ---------- Previous update was at 12:32 PM ----------

In repsonse to methyl's suggestion: in this case I need the user to do something external to the script just after starting the script, before proceeding so a command line parameter does not work. Thanks.
# 7  
Old 05-29-2012
Quote:
Originally Posted by twk
Not to mention that the output for the user is "lost" in nohup.out even if it's FG script. I guess I will have to break the script into two parts in separate files.
A nohup-ed script can still open /dev/tty by itself and write to it. But reading just won't work.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh behavior in scripts spawned w/nohup

I have a need to run any number of identical scripts simultaneously, so I've created a driver script which reads a template script, edits these appropriately and then submits them via nohup. The spawned scripts all check to see at some point how many of their number are running and once the count... (7 Replies)
Discussion started by: safedba
7 Replies

2. Shell Programming and Scripting

I need to save a pid of a child started with $: su <user> -c “nohup …”

Hello, I want to save pid of a child process but I get empty file. su myuser -c "nohup ./mydaemon.sh >/dev/null 2>&1 & print $! > mydaemon.pid" This one works: nohup ./mydaemon.sh >/dev/null 2>&1 & print $! > mydaemon.pid Please help. Thank you in advance. (2 Replies)
Discussion started by: vincegata
2 Replies

3. Shell Programming and Scripting

Expect script - Interact help

Hi Guys, Further to my post yesterday I have got round the issue of not being able to use expect by using one of our unix machines to have the script running instead of the jumpbox itself. However my issue is I now have an extra bit it the script which is shh to the jumpbox which requires a ras... (1 Reply)
Discussion started by: mutley2202
1 Replies

4. UNIX for Advanced & Expert Users

Help with ksh script to list, then cp files from a user input date range

Hi, I'm quite new to ksh scripting, can someone help me with this. Requirements: I need to create a script that list the files from a user input date range. e. g. format of file: *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00*... (1 Reply)
Discussion started by: chococrunch6
1 Replies

5. Programming

How could I interact with shell script from webportal written in php?

Hello, I am new on PHP scripting .I have shell scripts which I an running currently from linux server but now I want to make a web portal from where I will run all my scripts but the problem is all my scripts ask for parameters so I am getting confused how could I run my shell script from web... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

6. Shell Programming and Scripting

Expect script exiting too fast if used without interact.

Hi I'm working on an Expect script that is supposed to log-into a remote server and run some steps and exit. In the script I first spawn a 'ssh' session to the server and then after logging in I 'send' all the necessary steps ( with a '\r' at the end, so that they get automatically executed the... (3 Replies)
Discussion started by: clakkad
3 Replies

7. UNIX for Dummies Questions & Answers

Expect "interact" fails when called from another script

So, I have an expect script (let's call it expect.exp) that takes 3 arguments. It logs into a remote server, runs a set of commands, then hands control over to the user by the "interact" command. If I call this script from the command line, it works properly. Now I'd like to apply this script... (2 Replies)
Discussion started by: treesloth
2 Replies

8. Shell Programming and Scripting

How to make shell script interact with program

Hello all! I have a C program that runs on a loop, prompting the user for input until it is exited. I want to create a shell script that can run this program and provide input. How can I do this? I have investigated 'expect' and piping to stdin, but haven't had any success. Any help is... (2 Replies)
Discussion started by: radish04
2 Replies

9. UNIX for Advanced & Expert Users

Find the process was run using nohup or ksh.

Hi, I want to write a script which should be run only on foreground. Is there any way that the script can check itself whether it was run using nohup or ksh and if the user runs the script using nohup then it should prompt the user to run it using ksh? If (The user triggers the script using... (4 Replies)
Discussion started by: RRVARMA
4 Replies

10. Shell Programming and Scripting

can a shell script interact with database?

Hi All, Language like C,Java can interact with database..and can use database information .. can a shall script do this? if yes thn plz guide me..... thankx (7 Replies)
Discussion started by: johnray31
7 Replies
Login or Register to Ask a Question