Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Linux and Unix
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel firefox hard drive hardware internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Solved: ksh how to show ps -ef ?

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
surfnschultz's Avatar
Senior Member with 191 posts.
 
Join Date: Nov 2003
25-May-2005, 02:21 PM #1
Solved: ksh how to show ps -ef ?
I want to list the processes I am about to kill and ask the user for confirmation.

So my questions is how to make this command show on the screen

echo ps -ef | grep $portnum


this doesn't work as is in my script
tsunam's Avatar
Senior Member with 1,246 posts.
 
Join Date: Sep 2003
Experience: Linux~su
25-May-2005, 04:56 PM #2
well the echo is going to echo "ps -ef" ....as in the letters

you should be able to do a la="ps -ef | grep $portnum"
echo la
surfnschultz's Avatar
Senior Member with 191 posts.
 
Join Date: Nov 2003
25-May-2005, 07:14 PM #3
cool let me try that out asap.
surfnschultz's Avatar
Senior Member with 191 posts.
 
Join Date: Nov 2003
25-May-2005, 07:19 PM #4
Nope did work says varible la not fuound? weirdness....
surfnschultz's Avatar
Senior Member with 191 posts.
 
Join Date: Nov 2003
25-May-2005, 07:24 PM #5
now no error BUT no output to screen

la="ps -ef | grep $portnum"
echo la
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
25-May-2005, 07:47 PM #6
Back Ticks.
surfnschultz's Avatar
Senior Member with 191 posts.
 
Join Date: Nov 2003
26-May-2005, 11:10 AM #7
ps -ef | grep $portnum > $2

this worked, it is funny how you can be in the bathroom and think OH **** I figured it out. hahaha
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
26-May-2005, 06:00 PM #8
The Back Ticks would have worked as well. Anytime you want to echo the output of a command or assign it to a variable, you need to enclose the command in `Back Ticks`. Otherwise your echo command or your variable will just equal the characters you typed.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
29-May-2005, 12:02 AM #9
A few thoughts:

surfnschultz:
now no error BUT no output to screen
la="ps -ef | grep $portnum"
echo la

You have echoed just "la" to the screen, not the contents of the la variable. Try echo $la instead.

squashman:
The Back Ticks would have worked as well. Anytime you want to echo the output of a command or assign it to a variable, you need to enclose the command in `Back Ticks`. Otherwise your echo command or your variable will just equal the characters you typed.

Pretty much right. You can also simply execute the command to display the output to the screen; as you point out, back ticks are especially useful when you want to capture the result of a command, but you can display the result without using back ticks.

surfnschultz:
Not sure what you are doing here, but suspect a typo. You can certainly execute the ps -ef command in your script, and without any additional magic, the output will be displayed on the screen. The redirection to $2 (which I suspect is either a typo or superstitious behavior ) is not needed. My guess is that $2 is NULL (i.e., there is no second argument to your script, and your redirection to $2 resolves to a redirection to (NULL string) which is effectively stdout -- what the command would have done anyway. I may have misunderstood what was going on, however, so please let me know what I've missed.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
29-May-2005, 07:21 PM #10
Glad you come around once in a while CodeJockey.
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 03:42 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.