1

Have a basic batch script which updates a postgreSQL table with the users MAC against what is hard coded within the script. When I run it, it thinks both the MAC addresses are different or my syntax it not working. I have tried echo out the variables and they look the same.

Where am I going wrong?

Thanks

@echo off

set mac=00:00:00:00
echo %mac%
set /p mac_address= Please enter the MAC address 
echo %mac_address%
if mac==mac_address (

set /p hostname= Please enter the server ip address 

echo "update license set lldld" >> run
SET PGPASSWORD=xxxxxxxxxx
postgresql\bin\psql -U postgres -h %hostname% -p 5434 -d jasperserver -a -f run
del run

) else (
Echo "Error with MAC code"
pause

    )

1 Answer 1

2

The expression if mac==mac_address compares the texts mac and mac_address not the content of the variables.

You (nearly) always need to expand variables with percents or exclamation marks.

if "%mac%"=="%mac_address%" echo Same
Sign up to request clarification or add additional context in comments.

1 Comment

Doh! Been a long time, that's my excuse and I am sticking to it. Thanks so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.