Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-04-2009
Member
 
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!
Reply With Quote
  #2  
Old 27-04-2009
Member
 
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.
Reply With Quote
  #3  
Old 27-04-2009
Member
 
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 ...
Reply With Quote
  #4  
Old 27-04-2009
Member
 
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 ...
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 12:53 AM.