Mohammed Salah
Mohammed Salah

Reputation: 101

Press enter key in a shell script and ignore nohup output

I have a basic shell script that I made for deploying my packages...

I am facing 2 issues while executing the command

nohup /home/username/wildfly/wildfly-20.0.1.Final/bin/standalone.sh &

Its keeping me frozen and saying the below

nohup: redirecting stderr to stdout

If I run this command in a normal way, I should press ENTER and the process will keep running in background fine. So, my question is there any way to simulate that ENTER key stroke?

I have also an scp command to copy a file to another server and it's required to enter password after executing it, is there a way to enter the password through myscript.sh and press ENTER key?

scp /home/username/myfile.war 0.0.0.0:/home/username/myfile.war

Thanks in advance :)

Upvotes: 0

Views: 1827

Answers (1)

Gordon Davisson
Gordon Davisson

Reputation: 126078

It shouldn't actually freeze you, just look confusing because it has the "nohup:" message after the prompt for your next command (and then you need to press enter to get a new prompt). But you should be able to avoid the message by redirecting stdout and stderr yourself:

nohup /home/username/wildfly/wildfly-20.0.1.Final/bin/standalone.sh >/dev/null 2>&1 &

This sends both stdout and stderr to /dev/null, so nohup doesn't have to deal with them.

Upvotes: 1

Related Questions