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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Results from a secon batch file

Reply to Message Icon

Original Message
Name: elmoso
Date: April 30, 2003 at 08:14:16 Pacific
Subject: Results from a secon batch file
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


Report Offensive Message For Removal


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

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.


Report Offensive Follow Up For Removal

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

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


Report Offensive Follow Up For Removal

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

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

Thanx again


Report Offensive Follow Up For Removal







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








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge
Poll History




Data Recovery Software