LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-26-2009, 02:36 PM   #1
figo
LQ Newbie
 
Registered: May 2009
Posts: 14

Rep: Reputation: 0
Help! SSH and beyond


I want to ssh from a linux machine to another machine, log-on and issue some commands, then send command output back to my original machine.

I've thought about system("ssh ...; pwd; various commands") under C. But problem is that it only executes the ssh and leave the pwd and beyond. The semi-colon way does way in local machine but when you ssh it seems not working.

Besides, the result of executing at remote side need to echo back. Solving the problem under C is desired, and not to use system() to execute a script.

My another guess is thus to use popen or something similar.

Thanks a lot~

Last edited by figo; 05-26-2009 at 02:51 PM.
 
Old 05-26-2009, 02:54 PM   #2
sal_paradise42
Member
 
Registered: Jul 2003
Location: Utah
Distribution: Gentoo FreeBSD 5.4
Posts: 150

Rep: Reputation: 16
pwd as in present working directory or password?
your probably want to automate the process by giving the remote machine your public key in ~/.ssh/id_rsa.pub in the remote machine's ~/.ssh/authorized_keys
Try to use the commands in parentheses
Code:
ssh user@foo "command ; command2"
if that doesnt' work try using Expect library.
 
Old 05-27-2009, 08:26 AM   #3
figo
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by sal_paradise42 View Post
pwd as in present working directory or password?
your probably want to automate the process by giving the remote machine your public key in ~/.ssh/id_rsa.pub in the remote machine's ~/.ssh/authorized_keys
Try to use the commands in parentheses
Code:
ssh user@foo "command ; command2"
if that doesnt' work try using Expect library.
Thanks~ I think I found a solution anyway. Using system(ssh-automatic-logon-script) will do the trick.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh-agent, ssh-add and ssh-keygen AND CVS raylpc Linux - General 2 11-19-2008 02:50 AM
LXer: ssh-xfer: Quickly grabbing files over an existing SSH connection LXer Syndicated Linux News 0 08-08-2008 03:11 PM
setting up an ssh soxy or local ssh tunnel from within an ssh soxy Mangenius Linux - Networking 0 03-05-2007 03:15 PM
Passwordless SSH with SSH commercial server and open ssh cereal83 Linux - General 7 04-18-2006 12:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration