Linux scripting problem using ps command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Linux scripting problem using ps command
# 1  
Old 01-06-2010
Linux scripting problem using ps command

when I try to apply this principle to my script, is not working, it tells me something like 'command not found'

what i wrote is this..

Code:
if [$(ps -u $(id -u) | wc -l) -lt 5];
then echo "message1";
else echo "message2"; fi

I'm supposed to count number of processes of the user, and if they're five or more, then a message must come up.. when i use both commands alone, is working without problem..

:eek: what am i doing wrong? (oh by the way, is Linux platform)

Last edited by Neo; 01-06-2010 at 06:35 AM.. Reason: Added code tags for poster
# 2  
Old 01-06-2010
Code:
if [ $(ps -u $(id -u) | wc -l) -lt 5 ];




Spaces are required in both side.
# 3  
Old 01-06-2010
Double post.

Continued here.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Csplit command problem in Linux

Hi All, I have recently join the forum and this is my first post....hoping to get a suggestion to a problem that I am facing. I have a script that works well on ksh unix on AIX server. The below mentioned code checks number of records in an input file starting with 99 and splits it... (1 Reply)
Discussion started by: Sanjay_13
1 Replies

2. Shell Programming and Scripting

Problem with "make" command in Linux

Hi all, I downloaded an external program and extracted all the files to a folder. they have a make file which I have to run. But when I run make file I get an error g++ -O2 -c pgm.cpp make: g++: Command not found make: *** Error 127 When I checked the list of GCC I get this binf-01... (14 Replies)
Discussion started by: kaav06
14 Replies

3. UNIX for Dummies Questions & Answers

scripting problem

Hi I am doing scripting using EXPECT module. I have successfully created the code through which i can login automatically #!/usr/bin/expect spawn ssh 127.0.0.1 expect "abc@127.0.0.1's password:" send "xyz\r" now i want to create directory #!/usr/bin/expect spawn ssh... (0 Replies)
Discussion started by: esumiba
0 Replies

4. UNIX for Dummies Questions & Answers

scripting problem

HI -rw-r--r-- 1 synapse synapse 5242816 Jan 14 22:02 SMSCLOG.25 -rw-r--r-- 1 synapse synapse 1224138 Jan 14 22:14 SMSCLOG.26 below is the file which are generated after every 10 mins i am trynig do scripting in which latest generated file get cta and give ouput I use the below code ... (1 Reply)
Discussion started by: esumiba
1 Replies

5. Ubuntu

problem in linux ubuntu 10.10 about mail command

Hi, My question is that is there any substitute command for mail in ubuntu because I'm trying to run it and it is showing error: command not found!! Will it need to download any specific package? If so please tell me how can I download that pkg. Thanks in advance. (1 Reply)
Discussion started by: nageshgautam
1 Replies

6. Shell Programming and Scripting

Scripting problem

I have one table contains the last field is gender and it is entered in small letter ,i would like to convert to caps after checking the field? eg: eno ename loc gender 1 a ch f 2 b hy M 3 c hy m 4 d ... (1 Reply)
Discussion started by: mrbinoy
1 Replies

7. UNIX for Dummies Questions & Answers

Problem executing find file command in Linux

When trying to find a list of files with specific text in them using find . -type f -exec grep -l "DataStage Job 4263" {}\; I get error find: missing argument to 'exec' How can I correct this ? I'm on Linux Red Hat. Cheers PS I'm a DataStage programmer not a systems support... (4 Replies)
Discussion started by: jackdaw_at_work
4 Replies

8. UNIX for Advanced & Expert Users

scripting problem

hI I m very new to unix ,... I m facing an issue I have to search though a list of directorys, find all .gz files which are older than 7 days and delete that ,,, Any one knows a single command to do this .. Thnks in advance BInu (3 Replies)
Discussion started by: msbinu
3 Replies

9. Shell Programming and Scripting

scripting problem

Sorry everyone, i was able to fix it (0 Replies)
Discussion started by: bebop1111116
0 Replies
Login or Register to Ask a Question