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?
Posts: 12,087
Threads: 142
Joined: Dec 2002
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"
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.
Posts: 1,769
Threads: 410
Joined: Feb 2003
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?
the only way to create a logfile is by specifying '>' the app doesn't have the ability to create a logfile.
Posts: 1,769
Threads: 410
Joined: Feb 2003
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
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.
Posts: 12,087
Threads: 142
Joined: Dec 2002
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.
I just noticed that there was an update.
The SetCurrentDirectory did the trick. Thanks