Computing.Net > Forums > Disk Operating System > Sending file contents to environment var

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.

Sending file contents to environment var

Reply to Message Icon

Name: Chris Hodapp
Date: April 14, 2002 at 12:53:58 Pacific
Comment:

Okay, I was doing some simple batch
programming, and experienced the need
to somehow get the first line of some
files (I have a directory of files, and the
files contain the path to another file in
their contents as the first and only line)
into some usable form such as an
environment variable.
However, I have no idea as to how to do
this... I tried a couple things involving
redirection and pipes, as well as CON,
but none of them worked.
So, simply stated, could I redirect
something's output to an environment
variable instead of a file?

I guess that would not be required, and
there are probably other ways of doing it...
it would just enable to me to do what I'm
trying to do - which is view the contents of
a file which the path of is specified in
another file... and I need to integrate that
into a batch file - like I said, I have a
directory full of files that have the path to
another file in their contents. A file is
specified on the command line of the
batch file... and it needs to view the file
specified in that file's contents. I believe
I've stated that point enough now.

Thanks,
-Chris



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Dooom
Date: April 14, 2002 at 14:00:24 Pacific
Reply:

Hi Chris. Laurence Soucy did post the following script a couple of days ago (snipped script):

@ECHO off
:: ASCII Assembler by Laura Fairhead
ECHO XPYP[*'CC-\1P\QX,=P,APZ5O!PQ2O~5aaI~}Ksx>%temp%.\echos.com

ECHOS.COM will echo a string without CR/LF character on the end. So, use it like this:

@ECHO off
:: ASCII Assembler by Laura Fairhead
ECHO XPYP[*'CC-\1P\QX,=P,APZ5O!PQ2O~5aaI~}Ksx>%temp%.\echos.com
%temp%.\echos.com SET VAR=> %temp%.\temp.bat
type filename.ext >> %temp%.\temp.bat
call %temp%.\temp.bat
del %temp%.\echos.com
del %temp%.\temp.bat

Watch out for line wrapping. FILENAME.EXT is the file which has the string to be sent to %VAR%.

This script actually gets the text into FILENAME.EXT, inputs a prefix on it ("SET VAR="), send to a batch file and runs it.

-- Secret_Doom - Leonardo Pignataro --

PS: Hey Laurence, that ASCII code is very useful, I must say!

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


0
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: Sending file contents to environment var

Capturing output from a dos program www.computing.net/answers/dos/capturing-output-from-a-dos-program/8845.html

Backup large file to zip @ dos prompt www.computing.net/answers/dos/backup-large-file-to-zip-dos-prompt/5993.html

Send Messages ! Sending File ??? www.computing.net/answers/dos/send-messages-sending-file-/12153.html