Hi again, all..
Straight to the point..
Considering the attached code... If I type rxvt &
in an rxvt terminal, a new rxvt instance is opened, with rxvt (effectively) running its I/O on a bash shell process (it created?).
If I do something similar with rxvt -e myscript &
, nothing happens... or, at least, a process is created and immediately exits (I'm guessing).
However, if I use a command like rxvt -e sh -c myscript &
, rxvt runs.. and has an attached bash shell process in which to run the script, even though it's (mostly) the same as the first command I tried which had its own shell process created.
"Why is it so?" (thank you Professor Julius Sumner Miller)
Fanx!
Code: Select all
#!/bin/sh
# spawn - an example of how I'm dealing with running a script visibly
# in an rxvt window and logging the operation
#
my_proc="`basename $0`"
my_proc_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
my_proc_filespec="$my_proc_path/$my_proc"
logfile=/tmp/${my_proc}.log
if [[ -z "$1" ]]; then # If nothing on the CLI...
echo ""
echo "$my_proc: CLI"
echo "$my_proc: My PID : $$"
echo "$my_proc: My PPID: $(ps -o ppid= -p $$)"
echo "$my_proc: About to spawn..."
# rxvt -title "$my_proc: Testing Shell rxvt" \
# -sb -bg orange -geometry 80x25+200+200 \
# -e "$my_proc_filespec TEST 2>&1 | tee ${logfile}" &
rxvt -title "$my_proc: Testing Shell rxvt" \
-sb -bg orange -geometry 80x25+200+200 \
-e sh -c "$my_proc_filespec TEST 2>&1 | tee ${logfile}" &
rxvt_pid=$!
echo "$my_proc: rxvt PID: $rxvt_pid"
echo "$my_proc: Log File: $logfile"
else # If any argument on the CLI...
echo ""
echo "$my_proc: DETACHED"
echo "$my_proc: My PID : $$"
echo "$my_proc: My PPID: $(ps -o ppid= -p $$)"
echo ""
echo -n "$my_proc: Countdown: "
for ((i = 10; i >= 0; i--)); do
echo -n "$i.. "
sleep 1
done
echo ""
echo ""
read -p "$my_proc: Press ENTER to close this window... " kinput
echo ""
fi
echo "$my_proc: Exiting..."
echo ""
# [eof]