
Im looking to write a bash script I can use as a cron for a program I use. I know what it would be like in w32 .bat language, but not sure how to port it to bash script.
Basically, I use hellanzb for downloading from newsgroups. I dump a nzb file in a folder, and the program autodownloads it. The problem is the program keeps the connections open to the usenet server even when its not downloading.
So i want to write a cron that runs every 5 mins or so and checks for the existance of a .nzb in the folder, and if it finds one, itll start the hellanzb program, and if it doesnt find one, itll stop it.
something like this:
Code:if exist /home/myname/nzb/*.nzb goto START :STOP /etc/init.d/hellanzb stop goto END :START /etc/init.d/hellanzb start goto END :END

ok after a bit of googling ive come up with this:
but wont work as it can only look for a single fileCode:if [ -e "/home/myusername/NZB/daemon.queue/*.nzb" ]; then /etc/init.d/hellanzb start else /etc/init.d/hellanzb stop fi


Perhaps use "find" or "ls" and check the length of the output?
Or look for an empty directory?

Why doesn't it work? You are, if I read right, only testing for the presence of any file in the queue, so testing for one or testing for many have the same end.

it dint like *.nzb
but just /* seems to work OK![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)