Solved

Connecting to a SSH Server

Posted on 2004-08-30
6
1,073 Views
Last Modified: 2010-07-27
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.
0
Comment
Question by:Spetson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Accepted Solution

by:
DarkCore_ earned 400 total points
ID: 11931584
In Delphi? Why don't do this as a cron task or a php/cgi in apache?

In Delphi you'll need a ssh-connection component ( I don't know about any free component ), parse text ... etc ... it will be so complicated.

If you have kylix you can do too a small server listening at any port which listens for a connection and recieves a packet ( a string ), then run the script, for example.

Edu
0
 

Author Comment

by:Spetson
ID: 11931827
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.
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 11931868
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.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:DarkCore_
ID: 11931992
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
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11933040
you can use TIdRSH (from Indy). This is Unix Remote Shell component and you can execute the shell script...
0
 

Author Comment

by:Spetson
ID: 11940253
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
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 108
Firemonkey DbLookupComboBox equivalent ? 2 76
Not able to call Delphi XE10 dll function from Delphi 6.0 4 53
update joined tables 2 69
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question