begin with a script testing if a program is running
begin with a script testing if a program is running
i'm trying to test whether wget is working still or not.
while [ wget is still running ] <----- but how should this look please.?
do
codes
done
while [ wget is still running ] <----- but how should this look please.?
do
codes
done
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
Re: begin with a script testing if a program is running
Update: how about something like (damn "'" versus "`"):enhu wrote:i'm trying to test whether wget is working still or not.
while [ wget is still running ] <----- but how should this look please.?
do
codes
done
Code: Select all
while [ `ps -C wget | wc -l` != "1"]
do
ps -C wget | wc -l
sleep 1
done
change my mind. or do i have to put it in /null ?
i still don't know how to put it in dev/null
any suggestions?
i've trying to create a script that will terminate the program once its running
so maybe
any assistance please
i still don't know how to put it in dev/null
any suggestions?
i've trying to create a script that will terminate the program once its running
so maybe
Code: Select all
if [ `ps -C wget | wc -l` == "1" ] > /dev/null
then
echo do nothing
elif [ `ps -C wget | wc -l` != "1" ];then
terminate
else
something else
fi
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
That should be "/dev/null"enhu wrote:can't even find the dev/null
It is a "device", and so the "null device" is located in the /dev/ folder.
I just checked, it is there.
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
I typically run 4.3.1enhu wrote:there's still no /dev/null in this puppy lucid
can't find it
But, I just booted my 5.1.1 CD, opened rxvt, and typed:
Code: Select all
ls /dev/null
I just "cat"-ed a file onto it ("cat junk > /dev/null"), and it performed as expected (i.e. no error messages).
Open rxvt, and confirm that something didn't get messed up in your filesystem (does /dev/null show up in the directory list). You could also do this from the Puppy GUI, by browsing to /dev/ and see if the file "null" exists there.
I haven't tested your script code, but if you are getting errors from the code shown, I suspect that something about your code is incorrect, not /dev/null (error messages are often "obscure" and don't necessarily report the true source of the problem).
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
OK, looking at this... Why does it need /dev/null at all? I also think that is not the right location for use, if the code did need it.enhu wrote:change my mind. or do i have to put it in /null ?
i still don't know how to put it in dev/null
any suggestions?
i've trying to create a script that will terminate the program once its running
so maybe
any assistance pleaseCode: Select all
if [ `ps -C wget | wc -l` == "1" ] > /dev/null then echo do nothing elif [ `ps -C wget | wc -l` != "1" ];then terminate else something else fi
You are performing an "if" test, which should produce no user-visible output, it should only determine which way the choice "branches".
BTW, I think that your 3rd "option" cannot happen. Your operand is either "=1" or "not = 1", so the last "else" means...what?....
It is possible that if you clean up these 2 issues, the code will work (sorry, I'm not an expert at bash coding -- I can't tell by inspection)
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]
-
- Posts: 282
- Joined: Wed 16 Dec 2009, 21:38
- Location: Earth
Re: begin with a script testing if a program is running
You can use pidof. "pidof process_name". It returns "false" if process not found.enhu wrote:i'm trying to test whether wget is working still or not.
while [ wget is still running ] <----- but how should this look please.?
do
codes
done
SUUM CUIQUE.
Re: begin with a script testing if a program is running
while [ `pidof wget` ]; doPANZERKOPF wrote:You can use pidof. "pidof process_name". It returns "false" if process not found.enhu wrote:i'm trying to test whether wget is working still or not.
while [ wget is still running ] <----- but how should this look please.?
do
codes
done
okay so i did try this just to test
after running it returns an error saying
line 4 [: == : unary operator expected?
so what kind of file are PIDs?
Code: Select all
#!/bin/bash
APP=`pidof wget`
if [ $APP == "" ]; then
echo do nothing
fi
line 4 [: == : unary operator expected?
so what kind of file are PIDs?
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
PIDs are Process IDentifiers (a number which is created by the OS to identify a running process)enhu wrote: so what kind of file are PIDs?
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]