Link to home
Start Free TrialLog in
Avatar of Spetson
SpetsonFlag for Japan

asked on

Connecting to a SSH Server

Hello Experts.
I have a Linux RedHat9 box running SSH Server on port 22.
Now, i want write a small apllication in Delphi 7 that allow me to connect to this SSH Server.

What i want to do:
 1- Connect from my Windows XP to my Linux on port 22.
 2- Make login
 3- Execute a shell script (myscript.sh)
 4-Exit

I don't want use programs like putty because it's not necessary!
Everything that i want to do, is open my Delphi Application, enter my username and password, and click a simple button.
So, my Delphi Application will connect to the remote host, run my script and Exit.

Thank's in Advanced.
ASKER CERTIFIED SOLUTION
Avatar of DarkCore_
DarkCore_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Spetson

ASKER

huummm!
Ok, i will explain All my situation:
I will host a game server in my linux box...
Some members of my clan (game clan) don't know absolute nothing about ssh connection, telnet, etc...
So, i need something very simple for this guys...
a php or perl script sounds good, as my linux have Apache running at port 80, but i have already tested this option, without success...
The php script freeze's when start the script myscript.sh using exec() command or `myscript.sh`.

What the myscript.sh does:
1-Check if the game server is not running (avoid multiple instances), if it's running, kill it.
2-restart the application.

So, if you have some good idea, please let me know.

I Know that this topic area is about Delphi, but ANY SOLUTION for the Question will be very apreciate.

And...
About Kylix, i don't have this great program for linux :(
About cron task, the start/stop action, Must be interactive (user command) and not autamatic.

Thank's.
Avatar of Colin_Dawson
Colin_Dawson

You might want to check out the indy components.  That will give you the connection over port 22.  The SSH bit I can't help you with though.

in your script, try to run it with

   run_program &

to let it go to background.

In Apache the problem could be permissions. Be sure your apache ( with user Nobody ) have permissions to run your program. What kind of error does?

You can try too a simple sequence ... let the user install putty. Give them a 'standard' username and a password. In their .bashrc profile include some lines like

   ./myscript.sh &
   logout

Edu
you can use TIdRSH (from Indy). This is Unix Remote Shell component and you can execute the shell script...
Avatar of Spetson

ASKER

Ok guys!
It’s funny, but the found solution was not in Delphi, but using a php script that will do the entire job for me.
Thank you to DarkCore for all the support by email.
I decided to not post the solution here, as this Topic Area is about Delphi and not Php.
But anyways, if someone is interested in this question, please post your comments here and let us know.

Thank’s