Stuart Bailey wrote:
I'm trying to run a process that outputs to screen and file using tee. I allo want to capture the pid of the first process (not tee) into a file.
I'm using the following command line - the pid I want is that of xterm.
xterm -title "Test Terminal" -e 'bin/process | tee logfile' & echo $$
/tmp/process.pid
But I'm getting the pid of tee.
Really? That should give you the pid of the shell you're executing this in.
How can I change the command line to get the pid of xterm?
From bash(1):
$! expands to the process ID of the most recently executed back-ground (asynchronous) command.
It's the xterm you're backgrounding, and indeed $! gives me the PID of the xterm.
-- Martijn