I'm trying to create a ksh script to do the following:
1) Ask the user what process they want to search for.
2) Have the script read the input as a variable and use it to search for the process.
3) Display the current time & date, the working directory of the process, and finally display the information for only that process.
Ideal script output to the user:
current date here
1390: /home2/TEST/
root 1390 1 0 May 10 - 11:02 phantom EBC
Here is how I would manually perform the task:
# ps -ef | grep EBC
root 1390 1 0 May 10 - 11:02 phantom EBC
root 1652 1 0 Apr 17 - 0:22 phantom EBC
root 1884 1 0 Jun 04 - 4:43 phantom EBC
root 1912 1 0 Jun 22 - 7:08 phantom EBC
root 2314 3134 0 12:05:48 pts/3 0:00 grep EBC
root 2698 1 0 Apr 17 - 10:51 phantom EBC
# procwdx 1390
1390: /home2/TEST/
This is what I have so far but I know its not right, Please help
#!/bin/ksh
echo -n "Enter process name:"
read Answer
for i in `ps -ef | grep EBC | grep -v grep | awk '{print $2}'`;do
procwdx $i | awk '{print $1 $Answer}'| ps -ef | grep $1
done
echo $(date +'%D %T')