Computing.Net > Forums > Windows 2000 > pass values between batch scripts

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.

pass values between batch scripts

Reply to Message Icon

Name: tguns1177
Date: December 2, 2004 at 08:52:19 Pacific
OS: Win2k
CPU/Ram: -
Comment:

Hello,
Is it possible to pass values from one batch file to another? I have an exe that outputs a batch file with current date information. I need to pass the date values (year, month, day) into another batch file. The 2nd batch outputs a text file, and in the text file's name I must include today's date. How can i accomplish this?
I want to pass YEAR, MON, DOM from this file:
@echo off
Set YEAR=2004
Set PYEAR=2003
Set YR=104
Set PYR=103
Set MON=12
Set DOM=02
Set DOW=Thu
Set HOUR=10
Set MIN=48
Set YDOM=01
Set YMON=12
Set YYEAR=2004
Set YYR=104

into this file:
ENVTIME > Time.bat
RUN time.bat
ftp -n -s:geodeftp_get.scr
java -cp "G:\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script\GeodeFixSummary.class"; GeodeFixSummary GEODE.out fix.drkw.%YEAR%%MON%%DOM%.1.txt
G:\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script\files
ftp -n -s:geodeftp_send.scr
@echo Complete!
Explorer G:\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script
quit

Help!



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: December 2, 2004 at 09:13:16 Pacific
Reply:

Your post looks quite confused, the second batch does not follow common script rules (RUN Time.bat?). So clarify your needs as the problem can be solved, but in 2K/XP there are constraints on passing variables from one batch to another as there is no permanent common environment set up.


0

Response Number 2
Name: tguns1177
Date: December 2, 2004 at 11:11:58 Pacific
Reply:

sorry, let me clarify a bit...

The following batch file retrieves a file via ftp, sends it to a java class for processing, outputting a text document. The text is then saved locally. The batch runs perfectly - however, despite my best efforst, I cannot figure out a way to dynamically append today's date to the file and open it in notepad (or other default text editor). I have tried dating and naming the file in the java class, which worked nicely, but am unable to make the batch script open it, since it is a dynamic reference.

here is the .bat file:

Test.bat
1 ftp -n -s:geodeftp_get.scr
2 java -cp "G:\Portfolio\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script\GeodeFixSummary.class"; GeodeFixSummary GEODE.out
3 ftp -n -s:geodeftp_send.scr
4 start notepad xxxx.txt
5 @echo Complete!
6 quit

Line 1 retrieves a file from an ftp
Line 2 sends the log file to the java class for processing
Line 3 saves the output file to the local directory
Line 4 would open the output file in notepad for the user to display and work with - this is where the problem is

As far as i know, there is no way to pass a parameter (such as a string containing the date)from the java class to the batch. The other way would be to retrieve and format the date in the batch script, which i have no idea how to do.

I did find a utility, envtime.exe that retrieves current date info and stores them in another .bat file:

Time.bat
@echo off
Set YEAR=2004
Set PYEAR=2003
Set YR=104
Set PYR=103
Set MON=12
Set DOM=02
Set DOW=Thu
Set HOUR=10
Set MIN=48
Set YDOM=01
Set YMON=12
Set YYEAR=2004
Set YYR=104

Is it possible to run envtime.exe, have it output Time.bat and pass the date parameters (YEAR, MON, DMON) into test.bat, so I can name the file dynamically AND open with the 'start notepadd xxxxxx.txt' line?


0

Response Number 3
Name: Rick McNabb
Date: December 2, 2004 at 16:28:04 Pacific
Reply:

why not make a batch file that runs envtime, time.bat, test.bat and notepad?
something like this:

@echo off
envtime.exe > c:\temp\time.bat
call c:\temp\time.bat
call c:\temp\test.bat
start notepad c:\temp\test.txt
exit

If you do not specify folder for time.bat, system may try to run time command. Or, just change the name of the time.bat file to something like timedata.bat


0

Response Number 4
Name: Mechanix2Go
Date: December 2, 2004 at 22:19:29 Pacific
Reply:

I'm as confused as anyone.

But the simple answer is to send a parameter from bat1 to bat2:

call bat2 parameter

For multiple bats and exes, the environment varibles are the simplest way. Any bat or conforming exe / com has access the the varibles which you set.

M2


0

Response Number 5
Name: tguns1177
Date: December 3, 2004 at 13:13:24 Pacific
Reply:

Thanks for the feedback guys...simple parameter passing worked like a charm.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: pass values between batch scripts

Batch Script to count the string www.computing.net/answers/windows-2000/batch-script-to-count-the-string/65654.html

Need help with Batch script. www.computing.net/answers/windows-2000/need-help-with-batch-script/50848.html

Batch Script... www.computing.net/answers/windows-2000/batch-script/43991.html