My Script is having 2 command-line arguments and then just couple of questions, after these questions the script will run for itself, I'm able to pass the command-line argument by just doing,

-bash-3.2$ nohup ./Script.sh 21 7
nohup: appending output to `nohup.out'


Anyway to add the answers of these to-be-asked-questions with nohup?

  • What OS do you use? Is your nohup from coreutils? – cuonglm Sep 4 '14 at 5:00
  • -bash-3.2$ uname -a Linux -------------------------------- 2.6.18-238.5.1.el5 #1 SMP -----------05:52:39 --- ---- x86_64 x86_64 x86_64 GNU/Linux – Keyshov Borate Sep 4 '14 at 5:23

Instead of using nohup, you could have your script ask these questions interactively and then background and disown the remainder of whatever else it has to do.


$ more a.bash 

read a
echo "1st arg: $a"
read b
echo "2nd arg: $b"

echo "I'm starting"
sleep 10
echo "I'm done"
) &
Sample run:
$ ./a.bash 
1st arg: 10
2nd arg: 20
I'm starting
Check on it:
$ ps -eaf|grep a.bash
saml      6774     1  0 01:02 pts/1    00:00:00 /bin/bash ./a.bash
saml      6780 10650  0 01:02 pts/1    00:00:00 grep --color=auto a.bash
10 seconds later:
$ I'm done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.