D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] OT: Win/DOS "batch" programming question about variables...

 

Grant,

Try this...

Echo the Output from your Awk Script to a File
Then use the command set /p <Var>=<outputfilename>

Example:

        Echo Hello > Dave.txt
        Set /p Test=<dave.txt
        Echo %Test% gives 'Hello' on the command line.

Hope this helps.

Regards,
Dave.

-----Original Message-----
From: list-bounces@xxxxxxxxxxxxx [mailto:list-bounces@xxxxxxxxxxxxx] On
Behalf Of Grant Sewell
Sent: 20 February 2009 10:33
To: list@xxxxxxxxxxxxx
Subject: [LUG] OT: Win/DOS "batch" programming question about variables...

Hi all,

I'm trying to create a variable in a batch file that contains the
result of an application.  Under BASH I would do something like:

        var=`date`
        echo $var

Under "batch", if I do the following, it fails:

        set var=`date /t`
        echo %var%

This merely echos `date /t` to the command prompt.

What I'm actually trying to achieve is to have the output of an awk
script (a single line, showing the currently configured LAN IP address)
stored in a variable in the batch file for use later.

Any thoughts?  (other than "use perl/python/c++" :p)

Cheers.
Grant.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html


-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html