Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-25-2010, 03:33 AM   #1
Registered: Feb 2010
Location: Asekhshinuv Sacramento,Ca
Distribution: Slackware 13.0
Posts: 35

Rep: Reputation: 16
ps -A in script not showing full output

Hello everyone, i have a problem with ps, and pgrep when used in a script. with the -A option it does not print all processes and pgrep on a known running process returns nothing. So I made a script with nothing but "ps -A" and the shebang and it does show all of them. Also, ps -A on the command line is showing all processes. I am running this script as root and it is owned by root.

edit: I have ps -A in a function called in a case and if I put ps -A outside the function and case it shows all. how is where it's at changing it's output

Last edited by throughthegreens; 02-25-2010 at 03:45 AM.
Old 02-25-2010, 03:48 AM   #2
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
I recommend
`ps -A`
insted of
"ps -A"
Could you please provide us the code you tried till now?
Old 02-25-2010, 04:05 AM   #3
Registered: Feb 2010
Location: Asekhshinuv Sacramento,Ca
Distribution: Slackware 13.0
Posts: 35

Original Poster
Rep: Reputation: 16
backticks result in "PID: Command not found"

The problem was stoprouterconn was killing wpa everytime. I still don't think the ps -A looked full, but the script works now.
  3 WPA="wpa_supplicant -BD wext -i $IFACE -c /etc/Networks/CABLE1.conf"
  4 IFACE="wlan0"
  5 OUT="/var/log/networking"
  ### This gives full output
  6 ps -A | grep wpa_supplicant
  8 stoprouterconn() {
  9                 dhcpcd --release $IFACE 1>> $OUT
 10                 killall wpa_supplicant 1>> $OUT
 11                 ifconfig $IFACE down >> $OUT
 12                 /sbin/ifconfig lo up >> $OUT
 13         }       
 14 createnetclient() {
 15                 ifconfig $IFACE up >> $OUT
 16                 ### this returns nothing because ps -A doesn't show wpa_supplicant
 17                 ps -A | grep wpa_supplicant
 18         ### This returns nothing, wpa_supplicant is running though
 19         if pgrep wpa_supplicant
 20         then    
 21                 wpa_cli -i wlan0 reassociate 1>> $OUT 2>&1 &
 22         else    
 23                 wpa_supplicant -BD wext -i $IFACE -c /etc/Networks/CABLE1.conf
 24         fi      
 25                 dhcpcd $IFACE 1>> $OUT 2>&1 &
 26         }       
 28 case $1 in
 29         start)
 30                 createnetclient
 31                 ;;
 32         restart)
 33                 stoprouterconn
 34                 sleep 2
 35                 createnetclient
 36                 ;;
 37         stop)   
 38                 stoprouterconn
 39                 ;;
 40                 *)
 41                 printf "usage: stop|start|restart\n"
 42                 echo "  stop:           1=stoprouterconn()"
 43                 echo "  start:          2=createnetclient()"
 44                 echo "  restart:        (1) -> sleep -> (2)"
 45                 ;;
 46 esac

Last edited by throughthegreens; 02-25-2010 at 03:10 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Showing full path in Terminal. glore2002 Slackware 3 06-08-2008 12:26 PM
hard drive showing as full but isn't msound Linux - General 1 07-30-2007 10:21 AM
AS 2.1 Not showing full ram rashid68 Linux - Server 4 07-13-2007 04:24 PM
Xchat issue showing full IP address the-World-can-Wait Mandriva 1 06-22-2006 03:28 AM
Showing Full Path In Konsole Verbal Kint Linux - General 2 04-08-2004 03:10 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:15 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration