Batch Script – Logging

Configurare noua (How To)

Situatie

Batch Script is a file that consists of various commands which need to be sequentially executed. It is not like coding and is not frequently used, in order to communicate with the OS through a command prompt, the user can use Batch Script. The commands are known as Batch commands.

Logging refers to the process of converting the command line scripts into .log files or text files. The command processor creates real-time activity logs which collect all the information regarding batch commands and statistics.

Solutie

Pasi de urmat

Syntax samplegeeks.bat > samplegeekslog.txt 2> samplegeekserrors.txt

Example

1.) Create a file with the name “samplegeeks.bat”.

@echo off
echo "HelloGeeks">C:\samplegeeks.txt

These are the above commands for the execution of the batch files. Please execute in the command line to create a batch file.

Enter the below command in the above-created file.

net statistics /Server
The above command will show you an error as the Net Statistics command is given in the 
wrong way.

If the file got executed with the name  “samplegeeks.bat”. samplegeeks.bat > samplegeekslog.txt 2> samplegeekserrors.txt

Open the “samplegeekserrors.txt” file to see errors that occurred after executing the command.

The user will get an error as shown above because of the wrong syntax command execution of net statistics /Server.

The right syntax of the Net Statistics command is given below:

NET STATISTICS [SERVER/WORKSTATION]

The above screenshot is the right syntax output of the Net Statistics command. This command shows the network status and protocols. Users can easily show the level of User Datagram Protocol, Transmission Control Protocol, routing information, etc.

If the user still doesn’t get the error, the user can easily decode the errors with a simple below command.

 NET HELPMSG [numerical network]

Tip solutie

Permanent

Voteaza

(3 din 7 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?