How to run a ksh in bg after passing input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run a ksh in bg after passing input
# 1  
Old 12-21-2010
How to run a ksh in bg after passing input

Hello,
I've got a KSH which I use to monitor processes then email me when complete. I pass the process name to the script and the update interval.

Does anyone know how I can get this to execute in the background. I can't use 'scriptname &' as it starts in the background before reading in my variables.

Also, Doing cntl-z puts it in the bg but in a 'stopped' state.

Can I add something to the end of the script?
# 2  
Old 12-21-2010
If u r passing your input as command line arguments then, following will work.
Code:
scriptname val1 val2 &

And if u r prompting for an input then make a wrapper script for taking input and after then run your original script in background.
wrapperscript
Code:
echo "Enter val1:\c"
read val1
echo "Enter val2:\c"
read val2
originalscript val1 val2 &

This User Gave Thanks to For This Post:
R0H0N
# 3  
Old 12-21-2010
After suspending the job with ctrl+z you can use the bg command to tell your shell to continue your job in the background.
This User Gave Thanks to cero For This Post:
# 4  
Old 01-06-2011
Cheers all
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. UNIX for Dummies Questions & Answers

Passing Input To Function

May i please know why is it printing the script name for $0 when i pass those parameters to function. #!/bin/bash -x usage() { echo "In Usage Function" echo $0 echo $1 echo $2 } echo "printing first time" echo $0 echo $1 echo $2 usage $0 $1 $2 Output: (2 Replies)
Discussion started by: Ariean
2 Replies

3. Shell Programming and Scripting

Passing variables to an input file

Hi All, I have to insert 2 values to a text file in specific places. I have been able to extract each variable value via a script but am not able to send these variable values to the text file. Pasted is the script for extracting the variable values: for i in `ls -1` ... (2 Replies)
Discussion started by: danish0909
2 Replies

4. Shell Programming and Scripting

Passing a variable as input to another shell

I have a shell program that calls another shell program the following code works . chkTimeFormat.sh "10/9/12 17:51:19:783."|read c but when I am passing the the time in a variable like in the code below, the shell chkTimeFormat.sh is not returning proper value time="10/9/12... (9 Replies)
Discussion started by: swayam123
9 Replies

5. Shell Programming and Scripting

Passing value of variable in KSH

Here is a sample script demonstrating the issue x() { echo "foo" a=1 } ## the value of $a is 1 a=0 x echo $a ## the value of $a stays 0 a=0 x|sed "s/foo/bar/" echo $a Result: foo 1 (1 Reply)
Discussion started by: pbmarvin56
1 Replies

6. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

7. UNIX for Dummies Questions & Answers

Passing Shell Input to AWK

I am trying to search a log for a particluar pattern listing the total # of occurences in the end. I thought using a shell script for input then calling awk to search for the paramters specified. I want the script to be usable acorss envs. Code: #! /usr/bin/bash # get the variables... (5 Replies)
Discussion started by: wawa44oz
5 Replies

8. Shell Programming and Scripting

Passing input to perl command

Hi, In awk in can pass input to a command like this echo "1 2" | awk '{p=$1+$2;print v}'or I can use v option to pass input to awk command In the similar way How can I pass input to a perl command. For example : perl -pi -e 'if ( $. == 2 ) {print "Hello\n" }' input.txtIn the above... (1 Reply)
Discussion started by: john_noble
1 Replies

9. Shell Programming and Scripting

passing variables to sed in ksh

Hi, i need help passing variables to sed using ksh. My goal is to get particular data from log files. first i put a mark to the log files. echo "TEST_"`date + %m_%d_%Y_%T"` >markFile this will produce a 'markFile' which contain text like this TEST_06_01_2009_21:55:09 then i put the mark... (2 Replies)
Discussion started by: d.anggrianto
2 Replies

10. Shell Programming and Scripting

passing values to function in Ksh

Hi, I'm trying to work on the script given below #!/bin/ksh -x pfile() { echo "$1" } touch smp19 echo "Hi" > smp19 result=$(pfile $smp19) echo $result As highlighted , when i pass $smp19 as parameter ,it does not display the output.However when i try giving "Hi" instead... (2 Replies)
Discussion started by: Sheema
2 Replies
Login or Register to Ask a Question