For a hardware testing application, I have to run, and interact with, a couple of external cli applications, for example a Linux ping to a certain local IP address, from within a Tcl/Tk script.
In Windows 7 (and XP as well, a couple of years ago), I did this in a Cygwin environment, using Cygwin's Tcl8.5 and Expect 5.45, with good success. I could spawn a bash and then talk with 'ping', 'ls', 'touch' and several other tools using tcl's expect commands. When I close the bash afterwards with 'exit', the shell process finishes and I could repeat that with other commands as often as required.
In Linux (debian stretch), the same tcl/tk scripts run like a charm, including interaction with any external apps.
Now, by company policy, I'm required to make all this running under Windows 10. I read about, discussed with colleagues, and installed the windows subsystem for Linux (WSL) with a Ubuntu 18.04 wsl image, on my machine and ActiveState Tcl 8.5 (Windows version) and Expect 5.45 as well, via teapot.
The Tcl scripts themselves run as expected, including a wish GUI, serial comm and even ethernet comm from/to the D.U.T embedded hardware, but still I'm unable to start and talk with external programs, like ping and some other linux cli apps, using the wsl.exe interface.
If I start the wsl.exe manually, by clicking in Windows Explorer or from a (Windows CMD-) command shell, I get the bash prompt in the virtual terminal and can type all required tool commands interactively as to be expected.
But whatever I try to start wsl.exe from within my Tcl scripts, using the (Expect-) 'spawn' command or even simply:
exec C:\\Windows\\system32\\wsl.exe $lnxcmd $params ,
I get either 'file not found' for wsl.exe or no response at all.
What is the trick how to to execute wsl.exe and run a linux program from within a Tcl script running in the Windows domain, 'progamatically' and to interact (stdin/stdout/stderr handled by Expect) with it?
Even a '% dir C:\Windows\system32\ws*.exe' invoked from within the Tcl interpreter %-shell prompt (tclsh85 or wish85) shows not a single result, although the file WSL.EXE is definitely present within that Windows system folder?