Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
run command with > to logfile
#1
I have a little command file that I would like to convert to a macro, the part of the command file that I'm having trouble with looks like this:

C:\Program Files\tivoli\tsm\baclient\dsmc.exe i > d:\data\logfile.log

I would expect the macro to be:

run "dsmc.exe" "i > d:\data\logfile.log" "" "C:\Program Files\tivoli\tsm\baclient"

Of course the '> d:\data\logfile.log' are not actually parameters for dsmc.exe so it doesn't work. How can I route the output of my execution to a logfile?
#2
Try function system().

The system function executes an internal operating system command, or an .EXE, .COM (.CMD in Windows NT) or .BAT file from within a C program rather than from the command line.

The system function finds the command interpreter, which is typically CMD.EXE in the Windows NT operating system or COMMAND.COM in Windows. The system function then passes the argument string to the command interpreter.

Declaration:
dll# msvcrt system $cmd

Usage:
system "C:\Program Files\tivoli\tsm\baclient\dsmc.exe i > d:\data\logfile.log"
#3
Thanks, that works, but now I've lost the ability to specify the 'default directory' as I could when using run. The process fails because dsmc can't find the required files in the C:\...\baclient directory.
#4
what if you had it create the log file where ever it wanted and when it was through have it rename the file to the directory you want?
#5
the only way to create a logfile is by specifying '>' the app doesn't have the ability to create a logfile.
#6
i was thinking that it could create the file but it just wasnt where you would like it to be. if that was the case then i was just thinking that you could just put a quick
Code:
Copy      Help
ren C:\Program Files\tivoli\tsm\baclient\logfile.log d:\data\logfile.log
tag in the macro that would move the file to where you needed it.
#7
Use
SetCurrentDirectory "C:\...\baclient"
before system.
I tested it in similar situation, and it works. This function also can be used before run command instead of def. dir. argument.
#8
I just noticed that there was an update.

The SetCurrentDirectory did the trick. Thanks


Forum Jump:


Users browsing this thread: 2 Guest(s)