0

I have this script to open a new console, ssh into a server, run a deploy command.

I pass to the script the version of the deploy

xdotool key ctrl+alt+t
sleep 3
xdotool type "ssh myserver"
xdotool key Return
sleep 10
xdotool type "password"
xdotool key Return
xdotool type "sh path-to-script/deploy.sh $1"
xdotool key Return

I have several problems with this and I allready tried to google for a solution without success.

  • the character / its transformed to an &. when I run the script
  • copy&pasting in the console it works, but no if I run it as a sh file
  • the $1 is not evaluated

Can you give me any pointer in making this work. xdotool is not mandatory, I would use whatever it works

note: I can't by pass the ssh with a command becouse the security politics of the company and also don't know how to do it if I can't the settings in myserver

DiverseAndRemote.com
  • 19,314
  • 10
  • 61
  • 70
user2427
  • 7,842
  • 19
  • 61
  • 71

2 Answers2

0

Similar problem here: http://code.google.com/p/semicomplete/issues/detail?id=13#c29
Try:

xdotool type setxkbmap de
xdotool key Return
xdotool type "sh path-to-script/deploy.sh $1"
xdotool key Return

Maybe it works better if you write a script:

#!/bin/bash
xterm -e "ssh myserver \"sh path-to-script/deploy.sh $1\"; sleep 5"

and invoke it like this:

./theAboveScript.sh &
sleep 10
xdotool type "password"
xdotool key Return
surt91
  • 71
  • 1
  • 6
  • 1
    the second option is good, the problem is it jumps with exec request failed on channel 0. I tried with ssh myserver "ls" and same result, in other server it works, I think it may be server ssh configuration. Something I can't modify – user2427 Sep 26 '12 at 14:02
0

"expect" could be a good solution.

You can start following as a script with your parameter.

#!/usr/bin/expect -f
spawn ssh myserver;
expect "Password:";
send "password\n";
expect "me@myserver:~$";
send "sh path-to-script/deploy.sh $argv\n";
interact
surt91
  • 71
  • 1
  • 6