Variables _IFTP, _IFTPS: what about sftp connections?


Aug 22, 2013
I can detect is there is an active ftp connection by inspecting the variable _IFTP
I can detect if there is an active ftp session over ssl by inspecting the variable _IFTPS
But what if I connected with the sftp protocol? Is there any corresponding variable?
iftp sftp://user:[email protected]/directory/subdir/
echo %_IFTP
echo %_IFTPS

When I work interactively, I can just use the command IFTP to see if there is an active connection. It is enough to look at the output of the command on screen.
But I would like to write a batch file doing different things whether a sftp connection is active or not. I can imagine two other features that could help me handle this:
- Is there any way to capture the standard output of a command and put it into a command line? (something like command substitution in other kinds of shells)
- Or can I retrive the output of the last command and place it into a variable? Do I need to use any temporary file?

Suggestions for alternative approaches are welcome!