I have a Shell script that I originally wrote for an Ubuntu system with a desktop environment. The script makes use of gnome-terminal to open new terminal windows and execute certain commands. Here is the script:
#!/bin/bash VPN_USER="name"CONFIG_FILE="$(pwd)/vpn.ovpn"sudo echo "vpn bağlantısı"if ifconfig | grep "adress"; then gnome-terminal -- bash -c "ssh name@connection_adress"else gnome-terminal -- bash -c "sudo bash -c 'openvpn --config \"$CONFIG_FILE\" --auth-user-pass <(echo -e \"$VPN_USER\n$VPN_PASSWORD\")'" sleep 30 if ifconfig | grep "adress"; then gnome-terminal -- bash -c "ssh name@connection_adress" else sleep 30 fifi
This script works perfectly on an Ubuntu desktop, but I am now using WSL (Windows Subsystem for Linux), which is terminal-only. As a result, the gnome-terminal command does not work in WSL.
Could someone guide me on how to modify this script so that it works correctly in WSL? Specifically, I'm looking for a way to open a new terminal within WSL or to run the equivalent commands without needing a graphical terminal emulator like gnome-terminal.
Thank you in advance for your help!
I initially tried running the script as-is in WSL, hoping that it would open a new terminal or execute the commands in a similar manner to how it worked on Ubuntu with a desktop environment. I expected the script to either open a new terminal window within WSL or run the commands in the current terminal session.
However, since WSL does not support gnome-terminal or any graphical terminal emulator out-of-the-box, the script did not open a new terminal or proceed as expected. Instead, it simply failed at the points where gnome-terminal was invoked, and the associated commands did not execute.