Computer Hope

Computer Hope Forum Welcome, Guest. Please login or register.
November 22, 2009, 10:01:45 AM
Home Help Staff Chat Login Register
News: Have your own custom built computer? Come join the self-built computer club.

Computer Hope Forums  >>  Microsoft  >>  Microsoft DOS (Moderator: Computer Hope Admin)  >>  Topic: output to file problem 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: output to file problem  (Read 277 times)
jsheehan223
Topic Starter
Starter
*
Posts: 4

Thanked: 0
OS: Windows XP
Experience: Experienced


« on: October 29, 2009, 06:15:34 AM »

Hello,

I've got a batch file that I use to help me with my day to day activities.  I've come into a problem where I call a program and pipe the information to a file, but the information always comes out empty. 

I've posted the section of the batch file that's giving me trouble.  It works.  It will create the file, but no output goes to the file.  I've tried with >> and >, but neither seem to work.  I'm at a loss, really.  This really isn't my line of work, but something to help me day to day.  Any help would be greatly appreciated.  I believe the trouble line is in teal....

:DEFAULT_PWDS
M:
cd %CHECKPWD_DIR%
set /p PWD=Enter Password for %SLID%:
IF EXIST %CHECKPWD_DIR%\check_%ORACLE_SID%.log DEL %CHECKPWD_DIR%\check_%ORACLE_SID%.log
start /WAIT /D%CHECKPWD_DIR% checkpwd %SLID%/%PWD%@%ORACLE_SID% default_passwords.txt >> %CHECKPWD_DIR%\check_%ORACLE_SID%.log

start notepad %CHECKPWD_DIR%\check_%ORACLE_SID%.log

Thank you,

Jeremy
Logged
billrich
Guest
« Reply #1 on: October 31, 2009, 05:51:07 PM »

A pipe "|" is used to send input to another program.  If you send the information to a file, then a redirect (>) must be used


If you have used pipes, “|” with Unix Shell Programming or other environments, then a pipe with CMD (Batch) will not always work the same as other environments.
 
IF EXIST %CHECKPWD_DIR%\check_%ORACLE_SID%.log DEL

( in reference to the above line: You might CD to the directory where the log is and delete the log. ) ( If the log is not there, you will get a harmless message. )( a redirect will create the log automatically )

As a test use the real path and not the output of variables.

start notepad %CHECKPWD_DIR%\check_%ORACLE_SID%.log

I see no reason for start

cd to where the log is.

notepad oracle.log

We can open notepad with a batch file but the edit functions are manual.

Unix has  sed  which will run automatically

Good Luck



« Last Edit: October 31, 2009, 06:05:34 PM by billrich » Logged
jsheehan223
Topic Starter
Starter
*
Posts: 4

Thanked: 0
OS: Windows XP
Experience: Experienced


« Reply #2 on: November 04, 2009, 12:26:28 PM »

I appreciate the response, but I'm not worried about unix commands at this point. 

This works just fine when I run the steps manually.  It's when I put it into a larger batch file to help me with everything, no output goes to the file.  The file gets created (if it does not exist), but it's always a 0kb file. 

I tried your trick (taking out all the variable), but no dice.  It still does the same thing.  Creates an empty file.  btw, I developed with no variables and put them in after the fact. 

Any other suggestions?
Logged
jsheehan223
Topic Starter
Starter
*
Posts: 4

Thanked: 0
OS: Windows XP
Experience: Experienced


« Reply #3 on: November 04, 2009, 12:30:42 PM »

HA!  Figured it out.  For some reason it doesn't redirect when the START command is used.  I took out

start /I /SEPARATE /WAIT /D %CHECKPWD_DIR%

from the start and now it works like a charm....

SWEEEEEET!  I guess this can be considered closed. 
Logged
billrich
Guest
« Reply #4 on: November 04, 2009, 04:39:44 PM »

Good to hear you solved the problem.

I'm not sure why start can cause problems.

Start opens a new window and new copy of CMD.  Perhaps the file was there but hidden?
Logged
Geek-9pm
Expert
*
Posts: 2378

Thanked: 66
OS: Windows Vista
Computer: Specs
Experience: Experienced



Geek After Dark


« Reply #5 on: November 04, 2009, 04:54:59 PM »

Quote
Start opens a new window and new copy of CMD.  Perhaps the file was there but hidden?

A new copy of CMD is a bad idea in Batch programming.
Unless that is want you really want.
Logged
jsheehan223
Topic Starter
Starter
*
Posts: 4

Thanked: 0
OS: Windows XP
Experience: Experienced


« Reply #6 on: November 05, 2009, 06:56:42 AM »

I'm fairly new to batch programming so the advice is noted and appreciated. 
Logged
Pages: [1] - (Top) Print 
Computer Hope Forums  >>  Microsoft  >>  Microsoft DOS (Moderator: Computer Hope Admin)  >>  Topic: output to file problem « previous next »
Jump to:  


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright 1998-2008 by Computer Hope (tm). All rights reserved
Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC
Page created in 0.07 seconds with 18 queries.