Warning, Noob when it comes to scripts, but I have a problem with the script below-using cURL.
curl -L "%host%/cm?cmnd=Power%con%%%20On"
The Above code does not execute. %host% does not work but if I enter the IP address or %host1,2,3,..% it then works, but I need it to work with the %host% variable.
example 1 curl "%host1%/cm?cmnd=Power%con%%%20On" Works
example 2 curl "http://192.168.0.254/cm?cmnd=Power%con%%%20On" Works
example 3 curl "%host%/cm?cmnd=Power%con%%%20On" Does not Work
Works = The script inserts the correct host and the script executes its task by turning on the switch (Tasmota smart switch). correct inserted URL example: http://192.168.0.254/cm?cmnd=Power1 On
Does not Work = The script does not execute its task and the switch (Tasmota) does not turn on
It seems that %host% is not inserting the IP Address from set hostX=http://....
Also note the value for if%1==X is passed on via a program so I do not see the values added or the results or execution result of the batch script, Just the results of the Switch turning on or not.
@echo off
set host1=http:
set host2=http:
set host3=http:
set host4=http:
set host5=http:
set con1=1
set con2=2
set con3=3
set con4=4
set con5=
@echo off
if %1==7 set host=%host1% & set con=%con1%
if %1==8 set host=%host2% & set con=%con2%
if %1==9 set host=%host3% & set con=%con3%
if %1==10 set host=%host4% & set con=%con4%
if %1==11 set host=%host5% & set con=%con5%
curl -L "%host%/cm?cmnd=Power%con%%%20On"
Thank you
Earl L
What I have tried:
curl -L "%host5%/cm?cmnd=Power%con%%%20On" THIS WORKS
curl -L "http://192.168.0.254/cm?cmnd=Power%con%%%20On" THIS WORKS
curl -L "%host%/cm?cmnd=Power%con%%%20On" NEED THIS