Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Simple bat not working. Need some hints...  (Read 3066 times)

0 Members and 1 Guest are viewing this topic.

Ardiem

    Topic Starter


    Starter

    • Experience: Beginner
    • OS: Unknown
    Simple bat not working. Need some hints...
    « on: April 13, 2011, 04:27:41 AM »
    My ISP queues mail while my SMTP server is unavailable and unfortunately also sometimes queues it even while the SMTP server IS available. So, in order to dequeue the mail I run a finger command in a command window by typing:
    Code: [Select]
    finger [email protected]
    This runs properly and returns the number of emails waiting to be dequeued and then returns to the command prompt once the queue has been emptied. Now I don't want to have to keep doing doing this so I thought I could just enter that line into a bat file and schedule it to run every hour. However when I do that and run it, the command window opens and the command is run very quickly over and over again until I close the window.

    How should the bat file be written to just run the command once (properly) then exit?

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Simple bat not working. Need some hints...
    « Reply #1 on: April 13, 2011, 09:38:43 AM »
    Did you put this in a BAT file?
    Please include the full contents of the BAT.

    Ardiem

      Topic Starter


      Starter

      • Experience: Beginner
      • OS: Unknown
      Re: Simple bat not working. Need some hints...
      « Reply #2 on: April 13, 2011, 11:27:00 AM »
      Hi Geek-9pm

      I simply put that line into a text file and saved it with a .bat extension. (I also tried with a .cmd extension with the same results). I also tried it with pause after the line but that didn't do anything either.

      BAT file content:

      finger [email protected]



      Thanks

      A

      Fleexy



        Intermediate

      • OW NEXT TIME I SHOULD TURN IT OFF BEFORE SERVICING
      • Thanked: 2
        • Yes
        • Yes
      • Experience: Experienced
      • OS: Windows XP
      Re: Simple bat not working. Need some hints...
      « Reply #3 on: April 13, 2011, 03:58:22 PM »
      Try replacing that FINGER with PING
      I love .NET!

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Simple bat not working. Need some hints...
      « Reply #4 on: April 13, 2011, 04:16:36 PM »
      Quote
      However when I do that and run it, the command window opens and the command is run very quickly over and over again until I close the window.

      How should the bat file be written to just run the command once (properly) then exit?

      You problem can be recreated if the batch file is named finger and you're logged into the same directory where finger.bat lives. If that is the case, simply rename your batch file.

      Just a thought.  8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Simple bat not working. Need some hints...
      « Reply #5 on: April 13, 2011, 04:55:24 PM »
      Sidewinder, that's brilliant! Your are a genius!
      I could not duplicate what he did. That explains it!
      The command interpreter always looks in the current directory for a fie before looking into the PATH. That also explains why it was so quick. Finger  can take a few seconds. But the command interpreter did do invoke the real finger executable, instead recursively called the bat file name 'finger'.

      Kind of like taking two mirrors and looking at your face...face...face...face...face.....

      Ardiem

        Topic Starter


        Starter

        • Experience: Beginner
        • OS: Unknown
        Re: Simple bat not working. Need some hints...
        « Reply #6 on: April 13, 2011, 05:32:42 PM »
        I concur - sidewinder is indeed a genius. The file was in fact named Finger.bat (Doh!) so I renamed it to dequeue.bat and it works perfectly now. Thanks to Sidewinder and all those who PM'd me with suggestions.