Results 1 to 4 of 4

Thread: Log file for a DOS command

  1. #1
    Join Date
    Apr 2009
    Posts
    107

    question Log file for a DOS command

    Hello,
    I run DOS command "mkdir foo> toto.log.
    I creates the directory and log file, but it is empty.
    I wish that I put a little message like "foo directory created" or something ...
    Thank you for your help!

  2. #2
    Join Date
    Dec 2008
    Posts
    161

    Re: Log file for a DOS command

    Using the return code..

    Code:
    MKDIR TonDossier 
      if% ERRORLEVEL% = 0 Then  
      Echo "Created">> file.log Alejandro
    
      Else 
      Echo "Not Created">> file.log 
      End if
    I am not on the syntax but it must be something

    Clarification on the redirect command output to a text file:
    >: You replace in a text file
    >>: You write at the end of file

    In both cases, the file is created, so if it is for tracing, both used the ">>"

    And finally, know that in theory, any program returns an error code. 0 for success, the rest for chess.

    Know that as a developer, it is necessary that your program handles errors, and returns a value other than 0 in this case.

    Otherwise, the system will see that your program has finished, and return the value 0, whatever the result.

  3. #3
    Join Date
    Apr 2009
    Posts
    107

    Re: Log file for a DOS command

    Thank you for your answer, it has opened a track ...
    The syntax is actually not quite correct, but the coup I generate my log file with the sentence that I want.

    Code:
    MKDIR test2 
      if% ERRORLEVEL% == 0 (echo "Created">> test2.log) 
      else (echo "Not Created">> test2.log)
    Except that the tag else is not recognized, and it generates a file test2.log) Not Created with writing inside ...

    I tried replacing the last line by

    Code:
     if% ERRORLEVEL%> 0 (echo "Not Created">> test2.log)
    But it does nothing in the log if it fails to create the folder ...

    And for info, the only logs that I will generate my logs are existing DOS commands (copy, mkdir, ...) so they must all make a ERRORLEVEL ...

  4. #4
    Join Date
    Jan 2006
    Posts
    211

    Re: Log file for a DOS command

    If you are in an NT environment (for the production of your script), I advise you to go on the VBS and not DOS itself.

    The VBS is richer and more focused on development. "Bat" ...

    And more. "Def" syntax is a little chance ...

Similar Threads

  1. How to delete a file through command prompt ?
    By Girish-S in forum Windows Software
    Replies: 9
    Last Post: 14-10-2011, 08:19 PM
  2. How to work with if command and batch file
    By kolton in forum Operating Systems
    Replies: 5
    Last Post: 01-12-2010, 12:09 AM
  3. How to copy the specific file using “dd” command
    By Tallin in forum Software Development
    Replies: 3
    Last Post: 09-11-2010, 05:28 PM
  4. stringtokenizer in batch file / dos command
    By sayeed in forum Software Development
    Replies: 2
    Last Post: 14-10-2009, 01:26 PM
  5. .inf file will not run from the command line
    By CHRITOPHER in forum Windows XP Support
    Replies: 2
    Last Post: 31-08-2007, 01:53 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,619,054.52951 seconds with 16 queries