views:

101

answers:

2

Iditically simple I hope ...

I'm trying to create a bash command file on the fly from within an W7 DOS shell:

:: inside the .BAT file ..
:: check we are in the right directory
echo pwd > command.txt
:: get the shell to echo its environment variables
:: !!!! How do I get around this ... ?
echo echo $PWD

I thought prefixing the second echo command with a ^ (caret) would work but no ... anything welcomed

+2  A: 

I just tried

@echo echo %TMP%

which returned

echo C:\Users\Spike\AppData\Local\Temp

I think the problem wasn't the echo so much as the $PWD. %% is DOS for $.

Spike
+1  A: 

this works for me on WinXP

@echo off
:: inside the .BAT file ..
:: check we are in the right directory
echo pwd > command.txt
:: get the shell to echo its environment variables
:: !!!! How do I get around this ... ?
echo echo ^$PWD >>command.txt

output

C:\test>test.bat

C:\test>more command.txt
pwd
echo $PWD
ghostdog74