0
echo off
echo %1%
echo %2

set web = %web%
curl -I %web%

I have tried and have not been able to get it to work. My example file name is aa.bat

aa.bat https://www.google.com

This should result on the output of the command curl -I https://www.google.com

I cannot get it to return the required result.

Gerhard
  • 18,114
  • 5
  • 20
  • 38
w32442
  • 1
  • 1
    the first parameter is referenced as `%1`, the second one as `%2` etc. Where do you take `%web%` from? And `set web = %web%` creates another variable `%web %` with the value of `%web%` (which is empty as far as we can see) preceded with a space. – Stephan Aug 12 '20 at 20:07

1 Answers1

1

It is really not necessary to create a variable from stdin, but if it was needed:

@echo off
echo %1
echo %2   Rem Your example input does not show a second input parameter, so this will probably be nothing:
set "web=%~1"
curl -I "%web%"
pause

You can however just use the input %1 as is:

@echo off
echo %1
echo %2
curl -I "%~1"
pause

Usage:

aa.bat http://www.google.com

result:

enter image description here

So here are some valuable hints. open cmd and type help where you will find a list of commands. For each of these commands you find interesting, type command name, followed by /? for instance. set /? You will be able to find alot of useful information that will help you better understand batch-files and cmd. Also remember to run the help for cmd /? itself.

Gerhard
  • 18,114
  • 5
  • 20
  • 38