LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   bash applet (https://www.linuxquestions.org/questions/linux-software-2/bash-applet-363378/)

unihiekka 09-14-2005 02:42 PM

bash applet
 
Is it possible to make an applet (shortcut you just have to click) that starts bash and "types" ssh user@server.com, so I don't have to type the whole thing over and over again? How do you create it?

Thanks

morrolan 09-14-2005 02:57 PM

What about a bash-script either sat on your desktop or on your panel? That's all it has to be...

unihiekka 09-15-2005 02:13 PM

That would be fine with me, either of them... but I don't know how to write a shell script that starts bash with that line "ssh user @ server. com"...

morrolan 09-16-2005 08:58 AM

I'll look into this evening and write it if you still need the help :D

unihiekka 09-16-2005 09:38 AM

thx, that'd be great

morrolan 09-17-2005 02:32 PM

Sorry about the delay, I had things to do last night, but this is really easy as I've just tested it out.

First of all, in your home directory, create a directory called /bin or /scripts to keep all of your custom bash scripts in. This makes everything much easier in the future as you expand your knowledge of bash.

Open gedit or any other text editor, and write the following:

Code:

#!/bin/bash

# ssh shortcut to custom server

ssh user@www.server.com

#EOF

Obviously replace the user@www.server.com with your info.

My apologies if I'm teaching you to suck eggs here, but i'll briefly explain this.

The first line denotes that this is a bash script, and this a rough standard for most scripting languages.

The second line is simply a brief description of the script - pointless here but useful on longer scripts. Anything on the same line and after a # is a comment and is not part of the code.

The 3rd line is the one you want - this is simply the command exactly how you would type it on the command line.

The fourth line is a further comment which just denotes End Of File. Strictly speaking only the first and 3rd lines are required.


OK, now save it as say "connection.sh" where connection is whatever you want to call it. The .sh denotes that it's a script.

In GNOME right click on the file, goto Properties > Permissions and change the permissions so the owner can read write and execute. At the command line you would do this with: chmod 770 filename

Now that you can execute it, we need to create a custom launcher.

Right click on a GNOME panel and choose "Add to Panel..." then "Custom Application Launcher"

Choose a name for it, give a description in the comments field if you like, but in the command simply type "/home/user/scripts/connection.sh" or whatever the path is to your file. Click "Run in Terminal" and choose an icon, click OK, and that's it!

Now you should have a new icon, and when clicked (or double clicked) it should open up a terminal to your desired ssh connection. :D

Hope that helped.


(btw, the signature just below this is a bash script to check my fridge for beer and order some if it's empty...:D )

unihiekka 09-18-2005 07:05 AM

thanks that REALLY was helpful!!!

morrolan 09-19-2005 04:02 AM

I'm glad I could help!


All times are GMT -5. The time now is 06:59 PM.