-1

i have following code i want command line result save in my textfile also how do this. please help

@echo off

set JAVA_HOME=C:\jdk1.5.0_05

set CLI_HOME=c:\projects\utds\applications\cli
set CLI_LIB=%CLI_HOME%\lib

set CLASSPATH=%CLI_LIB%\commons-logging.jar;%CLI_LIB%\commons-logging-api.jar
set CLASSPATH=%CLASSPATH%;%CLI_LIB%\spring.jar;%CLI_LIB%\spring-core.jar;%CLI_LIB%\spring-support.jar;%CLI_LIB%\spring-remoting.jar
set CLASSPATH=%CLASSPATH%;%CLI_LIB%\utds-infra.jar;%CLI_HOME%\src\conf\spring;%CLI_HOME%\src\conf
set CLASSPATH=%CLASSPATH%;%CLI_LIB%\aopalliance.jar
set CLASSPATH=%CLASSPATH%;%CLI_HOME%\dist\cli.jar;%JAVA_HOME%\jre\lib\ext\comm.jar

set path=%JAVA_HOME%\bin;%path%

java -Dport=COM3 -DbaudRate=19200 -Dparser=panasonicCliParser -DappContext=applicationContext-service.xml com.utds.cli.service.comm.CallerIdListener

Save data into Textfile

Addi Khan
  • 119
  • 12
  • You just created another question with the same content. Like before, there is no magic to see here with just the bat code. Unless you are asking to send the result of the cmd to a text file, is that it? – dambros Apr 26 '16 at 10:08
  • yes.,.i want result save into my textfile – Addi Khan Apr 26 '16 at 10:09
  • You mean the output on the screenshot? – dambros Apr 26 '16 at 10:09
  • 1
    If you want all of the output fom running the command to go to a text file, then (if your bat file is called runme.bat), execute : runme.bat > file.txt – jr593 Apr 26 '16 at 10:10
  • basically this file automatic upate and show the callerid.. i want save this data into my textfile and sort callerid – Addi Khan Apr 26 '16 at 10:11
  • Then it sounds like you need to instead output that data to a file within the Java program, instead of outputting it to the console. – Darren Apr 26 '16 at 10:15

4 Answers4

2

I would pipe the output of the batch command into a text file by running the following command in the command prompt:

myBatchFile.bat > output.log
Ocracoke
  • 1,532
  • 3
  • 25
  • 36
1

Okay it looks like you're trying to put the output of the program into a text file. If that is the case, in your code just add:

java > log.txt
Darren
  • 1,367
  • 4
  • 16
  • 29
1

In my opinion, you should better use your logging library. I can see from the script here above that your applications uses Apache's commons-logging and the output shows it is clearly used.

This library is a wrapper indeed. It can use Log4J or JDK's logging library under the hood.

Of course, this requires much more learning and struggling with configuration files but the advantage for you is that you could (following the implementation you chose):

  • Filter logs following their gravity (debug < info < warning < error...) and/or the classes emitting them. Some libraries are quite verbose .
  • Create rolling log files : once the the log file reaches a certain size, a new log file can be created and the old one is backup-ed. (It can be possible to limit the number of backups...).
  • Create a log file per day
  • Log into databases if you ever need it... ....
C.Champagne
  • 4,706
  • 2
  • 21
  • 32
0

add only >mylog.txt Thanks All

java -Dport=COM3 -DbaudRate=19200 -Dparser=panasonicCliParser -DappContext=applicationContext-service.xml com.utds.cli.service.comm.CallerIdListener> mylogs.txt
Addi Khan
  • 119
  • 12