Scripts stopped in the shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripts stopped in the shell
# 1  
Old 07-15-2012
Scripts stopped in the shell

Hi,

I've been wondering about this for a while and I just don't know where to start looking. Some of my scripts always get stopped when I start them with
Code:
$ script.plx &

in the shell (bash, on Debian lenny, logged in via ssh from a Mac OS machine using Terminal.app). After a few seconds I keep on getting
Code:
[1]+  Stopped                 ./script.plx

If I do "fg" it goes on running, but I have to open another shell to work in until it's done. Not a "problem", but annoying. The particular script I'm working on at the moment (this may have nothing to do with it, I don't know) opens a bunch of windows on an X desktop using VNC, but I don't really care what happens there (I don't work directly in an xterm in the VNC window for speed issues and because there is a long standing keyboard mapping bug involving VNC and Gnome).

The problem is just so general it's difficult to google ("script stopped shell"???) :-/ If anyone can help me guess where to start, it would be really great. Thanks!
# 2  
Old 07-15-2012
Try to send it into background instead of fg:
Code:
bg

That's how I send into background running jobs, to reclaim my terminal prompt in bash: ctrl+z stops the job, and then bg will send it running but in background.
You can also use
Code:
bg %1

to background job number 1, which you can read from here:
Code:
[1]+  Stopped                 ./script.plx

What puzzles me is that running it with & should run it in the bg.

So, what shell are you using? On what platform?
# 3  
Old 07-15-2012
A background job that tries to read from its teriminal is sent a signal which suspends it (SIGTTIN). The same may happen when trying to write to the terminal (SIGTTOU), but that depends on terminal settings (tostop).

If that job requires some input, if it is known ahead of time what it needs, you can redirect it. If it's trying to write to stdout or stderr, you may need to redirect those (or fiddle with your terminal's settings, if an attempt to write is the problem).

You probably want to use nohup. Not only will it redirect all the standard file streams, but it will ensure that your script will survive should the terminal go away and cause the shell to send SIGHUP to its jobs.

Regards,
Alister

Last edited by alister; 07-16-2012 at 12:35 AM..
This User Gave Thanks to alister For This Post:
# 4  
Old 07-18-2012
Sorry for being unresponsive - I'm still working on that script :-/
Quote:
Originally Posted by mirni
Try to send it into background instead of fg:
Code:
bg

When I do that, it gets stopped again after a few seconds :-/
Quote:
Originally Posted by mirni
So, what shell are you using? On what platform?
I use bash, on Debian lenny, logged in via ssh from a Mac OS X machine using Terminal.app

---------- Post updated at 06:27 AM ---------- Previous update was at 06:22 AM ----------

Quote:
Originally Posted by alister
A background job that tries to read from its teriminal is sent a signal which suspends it (SIGTTIN). The same may happen when trying to write to the terminal (SIGTTOU), but that depends on terminal settings (tostop).

If that job requires some input, if it is known ahead of time what it needs, you can redirect it. If it's trying to write to stdout or stderr, you may need to redirect those (or fiddle with your terminal's settings, if an attempt to write is the problem).

You probably want to use nohup. Not only will it redirect all the standard file streams, but it will ensure that your script will survive should the terminal go away and cause the shell to send SIGHUP to its jobs.

Regards,
Alister
Thanks for the ideas. I just wanted to stay I'm still working on that script and investigating what the problem might be. I've used nohup in the past and I can't remember whether there were problems with that too or not.
# 5  
Old 07-18-2012
Try
Code:
nohup ./myscript.sh &

as suggested by alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn Shell script in stopped state while running in background

Hi, I want to run a shell script in background . but its going to stopped state $ ksh cat_Duplicate_Records_Removal.ksh & 8975 $ + Stopped (tty output) ksh cat_Duplicate_Records_Removal.ksh & why is this happening? Also could anyone please tell me what is a stopped... (12 Replies)
Discussion started by: TomG
12 Replies

2. Shell Programming and Scripting

shell script getting stopped at the middle.

I have created a shell scrit to run the informatica workflows sequentially.In the script i am executing 7 workflows sequentially after running 4 workflows the scrpt getting stop and it is not continuing next step evn it is updating logs.4th workflow will take more time to finish is that making... (1 Reply)
Discussion started by: katakamvivek
1 Replies

3. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

4. UNIX for Dummies Questions & Answers

New to shell scripts

Hi, Probably a real easy one for someone...I need to have a scheduled cp job run from crontab to copy certain files and directories to a shared NFS storage. The script I have works fine, except I need to exclude certain directories to stop issues with symbolic links, can someone explain... (2 Replies)
Discussion started by: paul.duncalf
2 Replies

5. Shell Programming and Scripting

Shell Scripts

deleted (1 Reply)
Discussion started by: zxc
1 Replies

6. HP-UX

Shell Scripts

I have a text file . Format of text file. djss:xd:78:isdev:"test server" this type of row. (approx 30). I want to display like that 1. djjs@msxd testserver 2. xjfd@msxd devserver 3. 4 select any one from above choice : 1... (5 Replies)
Discussion started by: rastogideepak
5 Replies

7. Shell Programming and Scripting

Help With Shell Scripts

if I run the below mentioned code, i am getting error. I dunno why. plz help me out this code runs a sql query and sends the result by email #!/bin/ksh # # Purpose: - Report Workflows that have Persistence turned ON echo "Workflow Persistence Report Started: `date '+%Y%m%d_%H%M%S'`" >>... (6 Replies)
Discussion started by: ragha81
6 Replies

8. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

9. Shell Programming and Scripting

shell scripts help

Hi, I am not experienced in shell scripts, I hope someone can give some hint for the following problem I have html file like this <html> <body> Some stuff More stuff <pre> A B </pre> Still more stuff And more <pre> C D </pre> Additional stuff </body> (2 Replies)
Discussion started by: ccp
2 Replies

10. UNIX for Dummies Questions & Answers

about shell scripts

Hi, i have made a script which makes some analyses on some differnet hosts. but i have a problem to make this script more quicker ... i would like to enter more a one hosts in the query (in my script are this: Pls enter the Hostname ... read hostname for i in $hostname do echo... (5 Replies)
Discussion started by: scottl
5 Replies
Login or Register to Ask a Question