+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, batch to bash rewrite help needed please in Coding and Web Development; Im looking to write a bash script I can use as a cron for a program I use. I know ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,510
    Thank Post
    1,319
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199

    batch to bash rewrite help needed please

    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

  2. #2

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,510
    Thank Post
    1,319
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    ok after a bit of googling ive come up with this:

    Code:
    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

  3. #3


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,460
    Thank Post
    866
    Thanked 845 Times in 667 Posts
    Rep Power
    195
    Perhaps use "find" or "ls" and check the length of the output?
    Or look for an empty directory?

  4. #4

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    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.

  5. #5

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,510
    Thank Post
    1,319
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    it dint like *.nzb

    but just /* seems to work OK

SHARE:
+ Post New Thread

Similar Threads

  1. .htaccess rewrite rule
    By localzuk in forum Web Development
    Replies: 2
    Last Post: 7th May 2008, 09:43 AM
  2. Exim rewrite rules
    By Geoff in forum *nix
    Replies: 2
    Last Post: 3rd March 2008, 10:30 PM
  3. batch file help
    By beeswax in forum Scripts
    Replies: 9
    Last Post: 3rd March 2006, 07:48 PM
  4. advice needed on weather a new server is needed
    By projector1 in forum Hardware
    Replies: 3
    Last Post: 24th February 2006, 09:20 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •