Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Batch Files

  • 13-03-2002 10:25am
    #1
    Closed Accounts Posts: 226 ✭✭


    Morning all,

    I want a batch file to pause once completed so I can check that it ran successfully.

    Anyone know what i need to add in?

    Cheers


Comments

  • Registered Users, Registered Users 2 Posts: 3,522 ✭✭✭Dr. Loon


    pause


  • Registered Users, Registered Users 2 Posts: 14,149 ✭✭✭✭Lemming


    Why not pipe the action carried out by the batch file to a .txt log or something so you can come back whenever and check at your leisure?

    Eg. under linux: cat myfile >> mylog.txt

    Ok .. that's a very simple way of piping to a text file I know, but you get the idea?


  • Closed Accounts Posts: 40 FireDragon


    i don't think this is much help but
    try something like said dir /p
    that alway let u check each part
    so use /p in ur batch file :confused:


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Rolo could be talking about not having the DOS box closing when you doubleclick it.

    You could create a short cut with the following command.


    command.exe /K batchfile.bat

    or for NT

    cmd.exe /K batchfile.bat

    This will leave the DOS box open. Lemmings idea is the better way to go.

    you would do the following..

    batchfile.bat > report.txt 2>&1

    what this does is outputs everything that goes to screen to a text file. The "2>&1" tells the command to send errors to the same file (some programs send it via the stderr pipe so it can be ignored in a normal pipe command).


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    as Dr.Loon pointed out, you can use the DOS command :

    pause

    You could try redirecting output to a file, but DOS/windows isnt as useful as linux for this, as (IIRC) it only redirects stdout, and not stderr - so error messages may not get logged to the file.

    jc


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Originally posted by bonkey
    You could try redirecting output to a file, but DOS/windows isnt as useful as linux for this, as (IIRC) it only redirects stdout, and not stderr - so error messages may not get logged to the file.

    jc

    *COUGH* *COUGH*

    :rolleyes:


  • Closed Accounts Posts: 226 ✭✭Rolo Tomasi


    tried the Batch command = .batchfile.bat > report.txt 2>&1

    but got this error in the textfile

    'batchfile.bat' is not recognized as an internal or external command, operable program or batch file

    What am I doing wrong?

    I'm trying to map a share and a printer that are on a different domain.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Well you never said what the name of your batch file was, so that was just an example.

    If your batch file was called MUPPET.BAT and was in the C:\mystuff directory then you would put the following into your shortcut.

    command.exe /K c:\mystuff\muppet.bat

    mapping a share and a printer would be the commands you put into a batch file and is a totally different question.


  • Closed Accounts Posts: 226 ✭✭Rolo Tomasi


    LOL

    Well you never said what the name of your batch file was, so that was just an example.

    I changed the file name for the sake of the post.

    The error still persists if anyone with a deeper knowledge of batch files wants to have a crack at it.


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    it doesn't know where this "program" you've tried to call exists: check your path (or if you are calling it from the cmdline directly try):

    C:\> c:\mystuff\muppet.bat > report.txt 2>&1

    instead of

    C:\> muppet.bat > report.txt 2>&1

    Al.


  • Advertisement
  • Closed Accounts Posts: 358 ✭✭CH


    does anybody know how to (or if you can) pipe the output to both the screen and a file, under DOS... ?

    regards


  • Registered Users, Registered Users 2 Posts: 1,842 ✭✭✭phaxx


    Originally posted by Dr. Loon
    pause

    Try using loon's suggestion...


    (fecks sake)


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    you can't pipe to the screen and a file at the same time.

    pipe is stdout so if you pipe to a file its not going to get to the screen

    What you could d0 is
    new file called test.cmd which contains your commands
    dir *.*
    new file called test2.cmd which contains your commands
    CALL test > test.txt
    type test.txt

    The call ensures that test has finished executing before the test.txt is displayed

    some code should be added to make sure test.txt exists


  • Registered Users, Registered Users 2 Posts: 3,522 ✭✭✭Dr. Loon


    Originally posted by phaxx


    Try using loon's suggestion...


    (fecks sake)

    Yeah, Jesus....

    pause

    Quite simple really. :)


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    *Newbies ignore*

    I notice your using .cmd instead of BAT which means your in an NT environment, if so a better batch file would be.
    dir *.* > text.txt
    call :readtext %1
    goto end
    :readtext
    type text.txt
    goto end
    :end
    

    That combines two batch files into one.

    *Newbies stop ignoring*

    You don't have to have two seperate batch files.

    something like.

    dir *.* > text.txt
    type text.txt

    would suffice.
    Originally posted by amen
    What you could d0 is
    new file called test.cmd which contains your commands
    dir *.*
    new file called test2.cmd which contains your commands
    CALL test > test.txt
    type test.txt

    The call ensures that test has finished executing before the test.txt is displayed


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    you are of course correct

    I only used the 2 files to make it a bit simpler

    your solution is somewhat more elegant


Advertisement