I would like to access the PATH environment variable inside an expect script.
How can I achieve that ?
My actual script is :
#!/usr/bin/expect set timeout 300 send "echo $PATH\r"
and its ouput is :
can't read "PATH": no such variable while executing "send "echo $PATH\r""
On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables.
To display the values of environment variables, use the printenv command. If you specify the Name parameter, the system only prints the value associated with the variable you requested.
Expect is an extension of Tcl. Tcl access enviroment variables via the global env
array:
send_user "$env(PATH)\n"
You can use the global env array by using:
$::env(PATH)
This notion will also work inside procedures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With