I am trying to create a simple bash script that will launch an app from the command line and redirect STDOUT and STDERR output to /dev/null. I also want to include functionality that provides feedback if the script fails.
The script almost works, but I can't get apps to launch in the background. I have tried using nohup, disown, wrapping the if statement in "(if...fi)&", wrapping the else statement in "{... ;}&", but everything I've tried has either introduced new problems or not worked at all.
Any suggestions?
Here is a basic version of what I'm doing:
#!/bin/bash
read -p "Enter program name: " APP
if
$APP 2>&1 | grep -q "command not found"
then
echo "That didn't work."
else
$APP >/dev/null 2>&1 &
fi