Reputation: 134
I have an AIX production server, there is a script A.sh
running on it.
i have no root access for this server.
i want to find out argument passing value of this A.sh
script.
How can i get this value?
Is there any provision inside /proc/processID
?
The following is not working. I tried by generating a script:
echo "Hello $1 $2 $3"
while [ 1 ]
do
sleep 2
echo $$
done
Then I run this script by
test.sh 1 2 3
Output:
$ cat /proc/3107/cmdline
-bash$
As per suggestion by @Cyrus suggestion I expect
1 2 3
which are the arguments I passed in, but it is not working like that.
Upvotes: 1
Views: 200
Reputation: 8032
This should work:
cat /proc/3107/cmdline | tr '\0' ' ';
Alternatively you can use:
ps -ef | grep script.sh | grep -v grep
where script.sh
is the name of your script which is running now.
Steps for verifying this:
Create a script named script.sh and paste the below code in it:
#!/bin/bash
while :
do
echo "Press [CTRL+C] to stop.."
sleep 1
done
Save the file (:wq!
from vi editor ).
Make it executable by
chmod a+x script.sh
Run the script by issuing command-line options like this:
./script.sh var1 val1 var2 val2 var2 val4
Open another terminal (duplicate session) and issue:
ps -ef | grep script.sh | grep -v grep
You should be able to see something like this:
username 12227 2268 0 07:48 pts/98 00:00:00 /bin/bash ./script.sh var1 val1 var2 val2 var2 val4 var4
Upvotes: 1