Reputation: 244
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
)
Upvotes: 1
Views: 150
Reputation: 82420
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
Upvotes: 2