![]() |
![]() |
#1 |
Dec 2011
After milion nines:)
2·32·7·13 Posts |
![]()
my script
Code:
echo "STATUS OF GFN PROCESS" echo "ps -C GFN22 --no-headers | wc -l" | //read number of process with this name read x if [ $x = 7 ]; then //compare with 7 echo "WARNING SOME WORKER DONT WORK" else echo "ALL WORKERS WORKING" fi echo `ps -C GFN22 --no-headers | wc -l` |awk '{print "PERCENTAGE OF PROCESS " $1*100/7 " % "}' if I echo "ps -C GFN22 --no-headers | wc -l" > x then x contain 7 : since 7 GPU run GFN22 process But script doesnot compare , since I can change anything and still showing all worker is running. I try $x and "$x" and some write Debian has own bash..... What I do wrong? |
![]() |
![]() |
![]() |
#2 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
150768 Posts |
![]()
Using normal quotes with echo: echo "ps -C GFN22 --no-headers | wc -l"
Elide the read x and try this x=$(ps -C GFN22 --no-headers | wc -l) |
![]() |
![]() |
![]() |
#3 | |
Dec 2011
After milion nines:)
2·32·7·13 Posts |
![]() Quote:
If I use normal quotes then command give me incorrect result. ( both are same: in first I use " in last line I use ` ) x=$(ps -C GFN22 --no-headers | wc -l) doesnot work still wrong result. Last fiddled with by pepi37 on 2022-10-17 at 23:51 |
|
![]() |
![]() |
![]() |
#4 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
2·3,359 Posts |
![]()
It seems weird to me that when x=7 you say some not working, but any other number means all working.
|
![]() |
![]() |
![]() |
#5 | |
Jan 2021
California
72·11 Posts |
![]() Quote:
ETA: retina got in their response while I was staring at this. Last fiddled with by slandrum on 2022-10-18 at 00:03 |
|
![]() |
![]() |
![]() |
#6 |
"Ed Hall"
Dec 2009
Adirondack Mtns
23·677 Posts |
![]()
Not sure, but don't forget = and == are different. You need == to compare.
|
![]() |
![]() |
![]() |
#7 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
2×3,359 Posts |
![]() |
![]() |
![]() |
![]() |
#8 |
"Ed Hall"
Dec 2009
Adirondack Mtns
23·677 Posts |
![]()
Hence, the "Not sure."
Another thought - what if you use "< 8" rather than "= 7" in your test? |
![]() |
![]() |
![]() |
#9 | |
Dec 2011
After milion nines:)
2×32×7×13 Posts |
![]() Quote:
echo "STATUS GFN PROCESS" x=$( echo `ps -C GFN22 --no-headers | wc -l` ) if [ x = 6 ]; then echo "ALL WORKERS WORKING" else echo "ALL WORKERS NOT WORKING" fi I can change x = 6 or x = 7 and will get again wrong answer: so script doesnot compare number 7 ( as result) with if then statement. In this case x is compared to 6 and since it is 7 all workers not working is correct answer, But if I change to x = 7 then again got same answer: all workers is not working. So for that I know script doesnot compare well . Last fiddled with by pepi37 on 2022-10-18 at 10:17 |
|
![]() |
![]() |
![]() |
#10 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
2·3,359 Posts |
![]() |
![]() |
![]() |
![]() |
#11 |
Dec 2011
After milion nines:)
2·32·7·13 Posts |
![]() |
![]() |
![]() |