I am fairly new to (bash) shell scripting and am in need of assistance.
Consider workstations A and B. I want to be able to log into workstation A and then from there log into workstation B. Once inside workstation B, I want to set the DISPLAY environment variable, run a script, then exit out and return to workstation A again to repeat this process for whatever number of workstations.
Below is my code:
Code:
#
# Workstation IP addresses
#
workstation[0]=10.0.0.1
workstation[1]=10.0.0.2
workstation[3]=10.0.0.3
#
# function : startClient()
# description: start clients at workstations
#
function startClients()
{
#
# Start all clients
#
for i in ${workstation[@]}
do
echo "Starting Client at $i..."
ssh -X $i # script stops here once I am ssh'd
DISPLAY=10.0.0.96:0.0 # into the remote workstation
export DISPLAY
/usr/local/abc/myscript.sh
echo "Exiting from $i..."
done
}
startClients
The obvious problem with this code (I know) is the ssh -X line. In particular, the script will stop running at this point which I do not want.
I've already tried these variations (a command delimited by semicolons and a command enclosed in quotes delimited by semicolons) with no luck:
Code:
ssh -X $i DISPLAY=10.0.0.96:0.0; export DISPLAY; /usr/local/abc/myscript.sh
Code:
ssh -X $i 'DISPLAY=10.0.0.96:0.0; export DISPLAY; /usr/local/abc/myscript.sh'
If I were to do this process from my workstation (A) manually, namely
Code:
ssh -X $i # after this command, inside workstation B
DISPLAY=10.0.0.96:0.0
export DISPLAY
/usr/local/abc/myscript.sh
then I have no problems.
Can someone please point me in the right direction? I need to be able to execute all these commands once logged into workstation B.
Thanks for your help!