Running commands over ssh
I need to write a small C program on Linux that'll connect to my other server and grab some info from other files. Is there any easy way to set up a ssh connection in C that'll look after this, or would it be easier to actually call out to the "ssh" program and work through that?
Thanks for any help! |
if its just grabbing files, look at scp. you can do that is a simple shell script...
|
Well, I need to pull out some status information from the other computer (/proc/cpuinfo, and stuff), I need to keep track of load and such. But I can make a call out to scp from the C program to get the files, do the analysis, and remove them. That'll work great!
Thanks! |
Hmm, apparently I can't do "scp othercomputer:/proc/cpuinfo ." -- it comes over as "0" bytes, the file isn't generated.
Anybody else else know how I can pull over a snapshot of these files? Thanks |
oh. /proc files.... /proc files dont really exist, theyre a bit of kernel memory.
|
I know that. But when you run a command on it, like cat, it outputs the appropriate content, which can be redirected into a file. I was hoping there'd be a way to copy them over the network easily, so I can analyze them remotely. It's sounding like it's going to be a lot of trouble.
I'm thinking I should run a server remotly that serves up the info on request, rather than fetching it. It's not a big deal if anybody who can connect to the server can get the info off it, it's nothing important (I want to be able to get info such as cpu usage, etc. on my network computers). |
why not ssh into the remote computer, cat all the files you need and redirect them to a text file, and then scp that file to your local machine (all done with a simple script). That's what I would do.
-twantrd |
you could use :
Code:
cat /proc/cpuinfo | ssh <remotehost> "cat > cpuinfo" or : Code:
ssh <remotehost> "cat /proc/cpuinfo" > cpuinfos |
Quote:
Code:
iago@Slayer:~$ ssh darkside "cat /proc/cpuinfo" > cpuinfos |
All times are GMT -5. The time now is 03:48 PM. |