Computing.Net > Forums > Disk Operating System > Results from a secon batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Results from a secon batch file

Reply to Message Icon

Name: elmoso
Date: April 30, 2003 at 08:14:16 Pacific
OS: Windows 2000
CPU/Ram: 1.8ghz/256MB
Comment:

Hello to all:
I'm having a little problem with 2 batch files I have. I will refer to them as 1.bat and 2.bat What I would like to complish is as follows. I run a weekly report off 2.bat, it is in it's own directory and the results are placed in there. My 1.bat file is used to find other data. I included the command in my 1.bat to call 2.bat. 2.bat runs fine, but the only problem I'm having is that the results are getting put in 1.bat's directory and not in 2.bat directory. Is there a way I can tell my 1.bat file to call 2.bat and the results that generate. To write out the results in 2.bat directory?
Another thing related to this is the following. In 2.bat's directory there is a prog called psort.exe. The prog runs fine when I run 2.bat from it's own directory, but when it is called from 1.bat. The psort.exe file does not run. Therefore not psorting out the results. I copied the file in my 1.bat's directory and the program runs, but can I make it run from 1.bat's directory instead, when 2.bat is called?

Thank You for your time



Sponsored Link
Ads by Google

Response Number 1
Name: Robbobob
Date: April 30, 2003 at 16:07:17 Pacific
Reply:

If 1.bat and 2.bat are in different directories, I would try putting in 1.bat a line before 2.bat is called that says "cd\batfile2dir" so that when 2.bat is run, it is run in its own directory. I take it that you have batfile2dir\2.bat as your execution of 2.bat wiht all this. Basically, you need to run 2.bat from it's own directory. Same deal with the other program, it needs to run in it's own directory.

I think this is an answer to your problem, I think.


0

Response Number 2
Name: Secret_Doom
Date: April 30, 2003 at 21:16:06 Pacific
Reply:

Yeah, probably 2.bat simply stores data to files without specifying their path, so the files are created on the current directory (which is not necessarily the batch file's directory).

As Robbobob said, a solution would be to change to 2.bat's directory before CALLing it:

pushd c:\2batdir
call 2.bat
popd

That would change to the directory c:\2batdir (representing the directory where 2.bat is located), call 2.bat and then return to the original directory.

Another solution would be to modify 2.bat, so it refers to files with determined paths. Let's say there's something like this on 2.bat:

echo Log begin>> logfile.txt

You would modify that to:

echo Log begin>> c:\2batdir\logfile.txt

Or perhaps:

echo Log begin>> %0\..\logfile.txt

Nevertheless, the first solution is probably simpler.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 3
Name: elmoso
Date: May 1, 2003 at 09:51:28 Pacific
Reply:

Thanx guys. That's exactly what I was looking for.

Thanx again


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Results from a secon batch file

Email from a DOS batch file? www.computing.net/answers/dos/email-from-a-dos-batch-file/4591.html

Batch file to Send Email?? www.computing.net/answers/dos/batch-file-to-send-email/14010.html

Need help in a dos batch file www.computing.net/answers/dos/need-help-in-a-dos-batch-file/12379.html