Prevent content of variables from showing in ps


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Prevent content of variables from showing in ps
# 1  
Old 09-03-2017
Prevent content of variables from showing in ps

system OS: ubuntu, redhat
shell: /bin/sh

i noticed that if im running a script and i go to a separate terminal and type:

Code:
ps -efauxx | egrep "<the-script-name>"


i see that the content of all the variables in the script are all visible. How can i avoid/prevent this?

the scripts in question are many and i cant paste them all in this thread. but, suffice it to say, most of the scripts are run through a pipe...i.e.

Code:
cat <script> | sh

any recommendations?
# 2  
Old 09-04-2017
Quote:
Originally Posted by SkySmart
system OS: ubuntu, redhat
shell: /bin/sh

i noticed that if im running a script and i go to a separate terminal and type:

Code:
ps -efauxx | egrep "<the-script-name>"


i see that the content of all the variables in the script are all visible. How can i avoid/prevent this?
What do you think
Code:
ps -efauxx

is doing? Explain every option. Explain why you need them all. Are you mixing UCB options (e.g. ps aux) with Posix options (e.g. ps -ef)?
Quote:

the scripts in question are many and i cant paste them all in this thread. but, suffice it to say, most of the scripts are run through a pipe...i.e.

Code:
cat <script> | sh

any recommendations?
Are you seriously running your shell-scripts by the above method? Or are you doing something more like this?
Code:
sh script1 | sh script2

Andrew
# 3  
Old 09-05-2017
Quote:
Originally Posted by apmcd47
What do you think
Code:
ps -efauxx

is doing? Explain every option. Explain why you need them all. Are you mixing UCB options (e.g. ps aux) with Posix options (e.g. ps -ef)?

Are you seriously running your shell-scripts by the above method? Or are you doing something more like this?
Code:
sh script1 | sh script2

Andrew

im doing something more like:

Code:
script1.sh | script2.sh

# 4  
Old 09-05-2017
~ Sigh ~

Quote:
Originally Posted by SkySmart
im doing something more like:
Could you, please, show us WHAT YOU DO, not "something more like...." what you do?

For questions about something more like whatever you do you will perhaps get something more like a solution instead of a real solution itself.

I hope this helps.

bakunin
# 5  
Old 09-05-2017
Quote:
Originally Posted by SkySmart
im doing something more like:

Code:
script1.sh | script2.sh

In that case you could consider using pgrep
Code:
ps -p $(pgrep -d, script-name) -F

or (I've just discovered this myself!) ps -C name
Code:
ps -F -C script-name

You can use the -o switch to define the output format of ps.

Andrew

PS I think your original problem with the environment variables was to do with mixing Posix and UCB command options. Your
Code:
ps -efauxx

was being interpreted as the UCB-compatible command
Code:
ps auxe

You cannot mix options with a - with options without a -
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to prevent Accidents 'rm -rf *'?

When invoking unix commands from other third party tools (IBM ETL), we run the rm / mv commands with the folder as argument been passed. Eg rm -rf {folder}/* when the parameter {folder} did not pass rightly or becomes blank, the command becomes dangerous to execute rm -rf /* How to prevent... (9 Replies)
Discussion started by: deepakwins
9 Replies

2. Shell Programming and Scripting

Facing issues with Content-Type:application/x-download Content-Disposition:attachment

I am in the process of developing a perl cgi page. I had succeeded in developing the page but there are few errors/issues with the page. description about cgi page: My CGI page retrieves all the file names from an directory and displays the files in drop down menu for downloading the... (5 Replies)
Discussion started by: scriptscript
5 Replies

3. Shell Programming and Scripting

how to prevent process from being killed

Hi,all.Well,I know someone has already asked this question before,however,It's too long before.So i post a new thread here. Here is the issue.I have a shell script that use awk to calculate something and the script takes about 15 mins,it will use 100% CPU,and the system automatically killed the... (2 Replies)
Discussion started by: homeboy
2 Replies

4. Shell Programming and Scripting

Comparing content of two variables

I have very abstract need of "comparing two variables" and take subsequent actions. please refer to image below https://lh3.googleusercontent.com/-frNk5iA3q1c/TjI3lE0sWOI/AAAAAAAAAIE/fxzB1w07gas/script_block.JPG I have a part of script which reads a file and generates variables based on... (4 Replies)
Discussion started by: animesharma
4 Replies

5. Shell Programming and Scripting

Help with remove duplicate content and only keep the first content detail

Input data_10 SSA data_2 TYUE data_3 PEOCV data_6 SSAT data_21 SSA data_19 TYUEC data_14 TYUE data_15 SSA data_32 PEOCV . . Desired Output data_10 SSA data_2 TYUE data_3 PEOCV data_6 SSAT data_19 TYUEC (9 Replies)
Discussion started by: patrick87
9 Replies

6. Shell Programming and Scripting

Moving Content from one file to another with variables

Greetings All, Need some help, your input is appreciated. Scenario: I have five files, each has one line with comletely different content. I execute the command to combine all the five lines of content into a single file. Goal: I would like to take that single file that has the... (3 Replies)
Discussion started by: royarellano
3 Replies

7. Shell Programming and Scripting

list file content as individual variables

Hello, I've created a couple of files within a list using the command "ls -ltr | tail -2 > list" These files are the newest files placed within a directory. From the "list" file, I need to place the filenames as a variable. In which the newest file will be called "new_ctrl" the older file... (4 Replies)
Discussion started by: petersf
4 Replies

8. Shell Programming and Scripting

comparing content of 2 variables in script

hello how can i compare the content of two variables using the if or for loops. I have 2 variables which was formed as result of commands pass into them but i want to now compare the 2 contents and echo where their is a match for examples variable1=`cat file2` variable2=`cat file3` if #... (5 Replies)
Discussion started by: sam4now
5 Replies

9. Shell Programming and Scripting

Put content of file into variables

How to put a line of strings (with some white spaces in between) from a file into variables? I have tried the following codes. However, the content is cut by space (not by line) for i in `cat ${source_file}` do echo $i done Please comment. Thanks. (2 Replies)
Discussion started by: Rock
2 Replies

10. Programming

how to prevent deadlock on this...

I am using linux termios structure to configure serial port and read the port by read function. For some reason, if I read the whole buffer, almost every time the buffer does not contain the correct reply message sequence from a device sending reply to my linux PC. So I use... (5 Replies)
Discussion started by: yimab
5 Replies
Login or Register to Ask a Question