Search code examples
xdotool

how to escape characters in xdotool


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


Solution

  • 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