about ksh ? /// for LINVIN FREE

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting about ksh ? /// for LINVIN FREE
# 1  
Old 04-04-2002
Bug about ksh ? /// for LINVIN FREE

(ps -ef | grep [p]rocessname >/dev/null 2>&1) \
&& echo "OK" \
|| echo "Not OK"

Thank you very much for your answer.
what is the effect of " >/dev/null 2>&1 "
I don't understand 2>&1

I'm just junior in programming Unix.
# 2  
Old 04-04-2002
No problem Smilie

The ">" sends output to wherever you want.
/dev/null is no-man's land. Anything going into the null device is removed. I use it a lot for this application: >/dev/null basically nulls out all output on stdout (the standard output mechanism).
What 2>&1 does, is send stderr (standard error) into stdout (standard output).
The numbers are actually "file descriptors"; 0 is input, 1 is standard out, and 2 is standard error.

So for example, you don't want to see any output, but you want to log error to a file, you could do:
./program >/dev/null 2>/tmp/my_log
A very common one I use is:
find /dir -name blah -type f >/dev/null
So when I get error about Permission Denied when trying to search a large amount of directories, it doesn't fill my screen - I just get the normal output without errors.

I don't know if I explained this very well... Can anyone else explain this better for me?
# 3  
Old 04-04-2002
that's well

thank you LIVIN FREE
Your answer helps me much.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Free UNIX with ksh, perl, Oracle and SQL

Is there a UNIX with ksh, perl, Oracle an SQL to download for free? If not, how can I "build" one? (9 Replies)
Discussion started by: Sygonion
9 Replies

2. Shell Programming and Scripting

different behaviour for ksh and ksh -x

I'm getting different behaviour when executing below script in debug option. $ cat ss.ksh ff=$(pwd) echo " ff : $ff" $ ksh ss.ksh ff : /tmp $ ksh -x ss.ksh + + pwd ff= + echo ff : ff : I was getting this behaviour in my actuall script i'm able to reproduce this in simple script... (4 Replies)
Discussion started by: luckybalaji
4 Replies

3. UNIX for Dummies Questions & Answers

Difference Between executing llike ./myscript.ksh and . ./myscript.ksh

Hi , What is the diffence between executing the script like ./myscript.ksh . ./myscript.ksh I have found 2 difference but could not find the reason 1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
Discussion started by: max_hammer
5 Replies

4. Solaris

MountPoint / is 8% with 899.49MB free crossing threshold of 10% free

Hi, I have a problem one of the server file system cross the limitation MountPoint / is 8% with 899.49MB free crossing threshold of 10% free out put please help how to resolve this dev/vx/dsk/bootdg/rootvol 9.8G 8.8G 956M 91% / /devices ... (3 Replies)
Discussion started by: sriniva0
3 Replies

5. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

6. Solaris

how to get the more memory free space (see memory free column)

Hi all, Could please let me know how to get the more memory free space (not added the RAM) in local zone. -bash-3.00# vmstat 2 5 kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr s0 s1 s1 s1 in sy cs us sy... (3 Replies)
Discussion started by: murthy76
3 Replies

7. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies
Login or Register to Ask a Question