1833421 Members
3112 Online
110052 Solutions
New Discussion

Very long command line

 
RikTytgat
Honored Contributor

Very long command line

One of the users at my site is running a command which is 1232 characters long, and wishes to view the complete commandline using ps. I know about the limit of 1024 bytes (used to be 64 bytes before 11i) of the command line that is stored in the kernel and about the ps -efx that shows up to 1024 characters of the command.

Is there any other way to view all of those 1232 characters of the command line? Maybe the arguments are stored in de process memory? And if they are, can I retrieve them from a running process?

I am aware that the command is ridicilously long, but shortening it is not an option!

Tnx in advance,
Rik
8 REPLIES 8
Leif Halvarsson_2
Honored Contributor

Re: Very long command line

Hi,
Not sure if it is possible to do exact what you as for but, it is possible to echo the command to a log file. I belive the command is started from a script or something (not typed in manually).
RikTytgat
Honored Contributor

Re: Very long command line

Leif,

I know what you mean, but other than helping my user, it made me curious, and after searching for several hours without finding a clue, I hoped to find some hints at the forums.

Thanks anyway.
Muthukumar_5
Honored Contributor

Re: Very long command line

If you set up history file then it is possible,

set -o vi
export $HISTFILE=$HOME/.sh_history
export $HISTSIZE=2000

Example>
# echo "hai" | sed 's/hai/bye/' | awk '{ print $1 }' | sed 's/bye/hai/' | awk '{ print $1 }' | sed 's/hai/bye/' | awk '{ print $1 }' | sed 's/bye/hai/' | awk '{ print $1 }' | sed 's/hai/bye/' | awk '{ print $1 }' | sed 's/bye/hai/' | awk '{ print $0 }'
# history -2
2459 echo "hai" | sed 's/hai/bye/' | awk '{ print $1 }' | sed 's/bye/hai/' | awk '{ print $1 }' | sed 's/hai/bye/' | awk '{ print $1 }' | sed 's/bye/hai/' | awk '{ print $1 }' | sed 's/hai/bye/' | awk '{ print $1 }' | sed 's/bye/hai/' | awk '{ print $1 }'

hth.
Easy to suggest when don't know about the problem!
RikTytgat
Honored Contributor

Re: Very long command line

You are right, but my user needs to see the command line of the running process.
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Very long command line

How about combining the above two:

ps -ef | grep Pid_of_process | awk '{print NF}' | grep sh_history
Vibhor Kumar Agarwal
Calin Valentin
New Member

Re: Very long command line

did you tried ps -efx ??
Ivan Ferreira
Honored Contributor

Re: Very long command line

Maybe you need to change the strategy. Like, before launching the process, echo the PID and the command line with args to a directory, more or less the information that you would find in /proc in linux.

Like:

echo $$ > /process/run/process_name
very_large_command_line >> /process/run/proccess_name
rm /process/run/process_name
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Andy Torres
Trusted Contributor

Re: Very long command line

I am very curious to see a command that takes 1232 characters. Any chance you could share it?