ps command in scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ps command in scripts
# 1  
Old 03-30-2012
ps command in scripts

I want to write 2 scripts that:
script named "users" - List of users logged into the system;
script named "ps" - List of all processes in the operating system;

Code:
# is it true?
#!bin/bash 
echo 'content-type: text/html'
echo
users # for script named users

Code:
#!bin/bash
echo 'content-type: text/html'
echo 
ps -a  # for script named ps

but when i use another OS (Ubuntu). for script "users" - nothing to show, and
for script "ps" - just show "PID TTY TIME CMD" Smilie
is there anyone can help me?

Last edited by numeracy; 03-30-2012 at 06:19 PM.. Reason: ps, users, scripts, shell
# 2  
Old 03-30-2012
#!/bin/bash should be the very first line. When you make it the second line, it's useless.

The output of ps is different in different versions of UNIX, yes.

Which kind and version of UNIX do you have? -- there are lots, UNIX is just a generic term. If you don't know, uname -a will tell you.
# 3  
Old 03-30-2012
Wouldn't help either as first line. There is a typo:
Code:
#!bin/bash

should be
Code:
#!/bin/bash

# 4  
Old 03-30-2012
#!/bin/bash => it's just my typing mistake here (in my CentOs - true) Smilie
to Corona688: scripts in CentOS: version 2.6.18
check html in Ubuntu: linux ubuntu 2.6.35-28
# 5  
Old 03-30-2012
Neither of those are UNIX at all.

It's entirely possible for a server to have no logged-in users, but make sure you're running it with the absolute path - /usr/bin/users

To show all processes in the operating system in Linux, ps aux
# 6  
Old 03-30-2012
following you advice: just receive that:
in CentOs:
Image
in UbuntuSmilienot show as we want)
Image
# 7  
Old 03-30-2012
That's not an ubuntu problem in particular, it ought to have the same version of ps as most other Linux. You may be in a chroot or otherwise restricted, unable to access that sort of information/

What does ls /proc do?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need equialent command for batch scripts

Hi Friend, what is the equivalent command for batch scripting of tail -1. for example : i have a.txt file with below the contents. i need to print last line --------------------------------- Use descriptive thread titles when posting. For example, do not post questions with subjects like... (3 Replies)
Discussion started by: Jewel
3 Replies

2. Shell Programming and Scripting

Command need to be used for the scripts output differences

Hi All, Actually we want to know the command need to use if the difference between two files are null, then it should not send as mail. Oterwise it should send as mail alert. Below for your reference, # Email the spoolfile. diff free_sp_new.log free_sp_old.log if output of above... (1 Reply)
Discussion started by: thanvir.akram
1 Replies

3. Shell Programming and Scripting

Running Two scripts in a single command line

Hi All, I have two scripts which i want to run in a single command line(or in a single script). And if both the scripts in the main script fail then i want to pass a value to a Application specific utility which will trigger some alert.The value can be anything. Somebody please help.It is... (1 Reply)
Discussion started by: shroh
1 Replies

4. Shell Programming and Scripting

set only some command & scripts permission to a particular user

hi, i am new in unix.......i am using bash and i want to create a user which has only some command and scripts permission.........is it possible? thanx (1 Reply)
Discussion started by: rakeshtomar82
1 Replies

5. Shell Programming and Scripting

Running shell scripts from command

I have written a few shellscripts to run a videogame (starcraft) at different patched versions. For example bw113 runs the 1.13 version of the game. These works perfectly when I run them from command line (./bw113). However I cannot get it to work via mouseclick. Some Information: - I have... (5 Replies)
Discussion started by: lordsloth
5 Replies

6. Shell Programming and Scripting

Invoking 2 scripts in 1 command

HI, I have 2 scripts main.sh and sub.sh, I want to invoke both these scripts in 1 unix command.. Something like... csh -f main.sh(sub.sh TIBCO) sub.sh returns a value as .., by taking this value main.sh prints a text. Can anyone help me to build this command Below are the scripts ////sub.sh... (3 Replies)
Discussion started by: bce_groups
3 Replies

7. UNIX for Dummies Questions & Answers

how to write perl substitute command in shell scripts

How to write perl substitute command in shell script without invoking a perl script file seperately. for ex: shell script to relace IT with CSC in a file using perl substitute command. (3 Replies)
Discussion started by: param_it
3 Replies

8. Shell Programming and Scripting

what's the debug command for perl scripts

Hi, Can you please let me know if there's any debug command for perl scripts like set -x for shell scripts (2 Replies)
Discussion started by: dayanandra
2 Replies

9. Shell Programming and Scripting

BUILT-IN command scripts

I am new to Unix scripting. I would like to know if someone can point me to a site which lists any built-in commands in there scripted form. I thought to start with the basics and learn from example. Thanks JSP (2 Replies)
Discussion started by: JSP
2 Replies

10. UNIX for Advanced & Expert Users

sqlplus and sh scripts (to_char command))

Hi evrybody!!!! I have a problem with this shell script INICIO=$(sqlplus -s user/user@db1 << END | awk '{printf $1}' set head off set feed off select to_char(min(create_dt) , 'HH24') from table_name where trunc(create_dt)=trunc(sysdate-2); END) I want to recover, in INICIO, the min... (4 Replies)
Discussion started by: josecollantes
4 Replies
Login or Register to Ask a Question