I have a simple batch script which transfers a file filename to a remote location destination using SCP.
Using scp filename destination works perfectly fine, however adding variable var doesn't work.
Code snippet:
set /p "var=filename"
echo %var%
echo scp "%var%" destination
scp "%var%" destination
Results:
filename
scp "" destination
: not a regular file
The variable is not used or recognized by the second echo and scp.
Is there something I'm missing from using the variable properly in echo and scp?
Note: Code snippet is in an if statement
Solution:
Need to use delayexpansion, and use !var! instead of%var%
See here: windows batch SET inside IF not working
Set /Pprompts for input. Whenfilenameappears on your screen, you're supposed to type it, and press the[ENTER]key. From what you've posted, it is clear that you are just pressing the[ENTER]key.