i'm trying to write a script to get the name and the pid of the process lanched from bash script.
example:
#!/bin/bash
pass=(`command1 | grep .... | tail ... `)&
if [ "$?" = "0" ]; then
echo "pid of the sub-shell "$!
echo "pid of the shell "$$
else
echo $?
exit 1
fi
the output of this script is
pid of the sub-process 22725
pid of the shell 22724
My question is how can i get the the pid and the command of command1 from shell script, and the result of the command in pass variable.
- if i remove the "&" i get the result of the command ( password) but not the pid of sub-shell
- if i set the "&" i get the pid but not the password