RabbieBurns Posted September 21, 2008 Posted September 21, 2008 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: 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
RabbieBurns Posted September 21, 2008 Author Posted September 21, 2008 ok after a bit of googling ive come up with this: if [ -e "/home/myusername/NZB/daemon.queue/*.nzb" ]; then /etc/init.d/hellanzb start else /etc/init.d/hellanzb stop fi but wont work as it can only look for a single file
tom_newton Posted September 22, 2008 Posted September 22, 2008 Perhaps use "find" or "ls" and check the length of the output? Or look for an empty directory?
powdarrmonkey Posted September 22, 2008 Posted September 22, 2008 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.
RabbieBurns Posted September 22, 2008 Author Posted September 22, 2008 it dint like *.nzb but just /* seems to work OK
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now