Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to create a launcher for the left bar on ubuntu 11.10, I followed this answer, and it works, but I want to auto login into the SSH servers, so I tried using a command I have used before, something like:

expect -c 'spawn ssh [email protected] ; expect assword ; send "password123\n" ; expect root@; send "unset HISTFILE\n" ; interact'

That works fine when typed on a console directly, but when I put it on my shortcut Exec= section, then I click the launcher icon and nothing happens, there's no terminal with ssh opened or anything else.

This is how the shortcut file loos like:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Name=Remote Servers
Comment=Login to my servers
Exec=notify-send "Select a server" "You have to select a server to SSH into" -i /usr/share/icons/gnome/256x256/status/messagebox_warning.png -t 5000
Terminal=false
X-MultipleArgs=false
Type=Application
Icon[en_US]=/home/username/.icons/ssh.png
StartupNotify=true
StartupWMClass=RemoteServers
X-Ayatana-Desktop-Shortcuts=Server1;Server2;

[Server1 Shortcut Group]
Name=SSH into 111.222.333.444
Exec=expect -c 'spawn ssh [email protected] ; expect assword ; send "password123\n" ; expect root@; send "unset HISTFILE\n" ; interact'
TargetEnvironment=Unity

[Server2 Shortcut Group]
Name=SSH into 111.222.333.444
Exec=expect -c 'spawn ssh [email protected] ; expect assword ; send "password123\n" ; expect root@; send "unset HISTFILE\n" ; interact'
TargetEnvironment=Unity

I though this would work because I've created another shortcut to launch a virtual machine, I created it using gnome-desktop-item-edit --create-new, and the command in "Exec=" is just the same as when typed on the console.

Anyone knows how could I get this working?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

put the entire expect command in a separate script , say ~/bin/server1 and change your Exec to

Exec="gnome-terminal -e /home/your_user/bin/server1"

I assume you do not want others to view/use the script as it contains a password, so chmod 700 ~/bin/server1 and consider using an encrypted home directory ;)

share|improve this answer
    
Exec=gnome-terminal -e "expect..." worked, but I had to use double \\" to en code quotes. –  rlihn Jan 8 '12 at 6:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.