Send job to Background after input redirection


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Send job to Background after input redirection
# 1  
Old 09-21-2012
Send job to Background after input redirection

Hi,
I am having issues with syntax when I am trying to send a job to the background after a input redirection.
I have this script which sends some files to different servers after zipping them. Once I execute it, it will ask for user input as of which server the files need to go to. (The filenames and location are coded for in the script)
The script comes out of the execution if no input is passed within 5 secs.

Code:
send_files.ksh <enter> 
Choose destination ->
                     etl1
                     etl2
                     etl3
                     etl4
                     ALL #to send to All servers

I execute this script using the following:
Code:
send_files.ksh > $LOG/Sep21.log 2>&1 <<EOF
 ALL
 EOF

By doing that, the script waits at prompt until it finishes execution.
For it to not wait until execution completes I was trying to submit this job in the background but i am not able to figure out a syntax for the same.

I have tried the following and it runs without taking in the 'ALL' input.
Code:
send_files.ksh > $LOG/Sep21.log 2>&1  & <<EOF
> ALL
> EOF

Any help would be much appreciated.
# 2  
Old 09-21-2012
Will it run to completion while still waiting for input?

try the at command:
Code:
at -k now <<!
( /full/path/to/send_files.ksh > $LOG/Sep21.log 2>&1  & <<EOF
> ALL
> EOF
)
!

# 3  
Old 09-21-2012
& terminates the command, just like a semicolon or newline. All redirections must precede it.

Regards,
Alister
# 4  
Old 09-21-2012
Quote:
Will it run to completion while still waiting for input?
@Jim. No, it wont run since it exits if no input is provided within 5 secs.
And thanks for the "at" command. But, is the placement of "&" correct in your command/script?

@Alister. Thanks. I didn't know that & terminates a command.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Several exec on find send all the output to the last redirection

Example script: find mydir -type f -exec echo {}>aaa \; -exec echo {}>bbb \;The two paths go the the bbb file, while there should be one of them on each file. How should I do it to get it working? (2 Replies)
Discussion started by: Tribe
2 Replies

2. UNIX for Dummies Questions & Answers

When do I use input redirection?

Can someone please explain when input redirection is necessary? For example, "cat filename" and "cat< filename" produce the same result. I was told that if I need to bunzip a file that I should type "bunzip2<filename.bz2." However, if I omit the "<" I still get the same result. Can someone... (4 Replies)
Discussion started by: PTcharger
4 Replies

3. Shell Programming and Scripting

Background Job

Hello Everyody, Having a doubt. sort file1 & when we sent a job to the background it returns Job Number PID again if we want to ... (1 Reply)
Discussion started by: knroy10
1 Replies

4. Shell Programming and Scripting

Send Foreground job to background redirecting output

I have many CPU intensive processes running and sometimes I run them in the foreground so that I can see what the output is. I want to send that foreground process to the background, but also have it direct the output to a logfile. I know to send something to the bg I do Ctrl-z on the FG... (6 Replies)
Discussion started by: jhullbuzz
6 Replies

5. Shell Programming and Scripting

Input redirection and for loop

Hello, I need help with a bash script that I try to improve. I could not find answer so far, maybe because I'm not to familiar with the terminology so feel free to correct my language. I have a script that looks like: NODES="node_a node_b node_c" for NODE in $NODES do ... (4 Replies)
Discussion started by: pn8830
4 Replies

6. Shell Programming and Scripting

input redirection question

Hi, in my script I need to execute the following command: query $id 456 432 but it waits for a RETURN character from keyboard and therefore, it fails. I tried something like: query $id 456 432 << '\n' but, i'ts clear it is not correct. Is there any way to do this? Thxs. (0 Replies)
Discussion started by: luistid
0 Replies

7. UNIX for Dummies Questions & Answers

background job

on gnome i open a terminal and run wget http://soommmething & in the background. because wget shows me downloading progress percentage and download speed continuously, I exit the gnome-terminal after a while i want to see the download percentage but dont know how. my ps -u myname shows that... (3 Replies)
Discussion started by: babayeve
3 Replies

8. UNIX for Dummies Questions & Answers

Background job

Hiya, Recently I've run a few scripts in the foreground, but have realised later they should of been better nohup'd and placed in the background. I understand how to change a foreground job into a background one, but how would put the job into the nohup state? Thanks (1 Reply)
Discussion started by: rdbooth
1 Replies

9. UNIX for Dummies Questions & Answers

background job

I try to run a script as background job. script: #!/usr/bin/csh /usr/bin/date +20%y-%m-%d > ~/datsql.txt If I start it I got this output: tac> ./datermitteln& 293 + Stopped (SIGTTOU) ./datermitteln& I insert the following line inside my script, but without any... (3 Replies)
Discussion started by: joerg
3 Replies

10. UNIX for Dummies Questions & Answers

Input Redirection

Hi everybody, first of all i am a new member in UNIX.com and this is my first post. I am impressed with the amount of information a person can ever have in this forum, it is really great having something similiar; anyways let me tell you about the problem I am having, hope you will answer me.... (6 Replies)
Discussion started by: majeed73
6 Replies
Login or Register to Ask a Question