So I know I can run a terminal command, ok?


What if I want to run say... a vi command or mkdir command INSIDE ssh?

If I want to make it insert a directory in a server via SSH, possible?

Last time I checked I think when you run commands like cd or run commands from the cd like ./mycommand from inside a C++ file and you run cd /usr first, it still runs the command from the folder the C++ file is in, I want to change the directory to what I want THEN run it.

That's just an example, I'm actually trying to make an auto uploader for SSH to make my job a bit faster.

Help?

OH ALSO, when you ssh it asks for password.... is there a way to submit the password? Same goes for running sudo commands...

So I know I can run a terminal command, ok?


What if I want to run say... a vi command or mkdir command INSIDE ssh?

If I want to make it insert a directory in a server via SSH, possible?

Last time I checked I think when you run commands like cd or run commands from the cd like ./mycommand from inside a C++ file and you run cd /usr first, it still runs the command from the folder the C++ file is in, I want to change the directory to what I want THEN run it.

That's just an example, I'm actually trying to make an auto uploader for SSH to make my job a bit faster.

Help?

OH ALSO, when you ssh it asks for password.... is there a way to submit the password? Same goes for running sudo commands...

Password less SSH? Sure. Here's a How-To:
http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html

You can run any command you want inside SSH. You can even run GUI apps from the SSH server if you really want. I'm a little confused as to what exactly you want to do though, but to answer a few of your questions:

a) If you want to run VI or mkdir then just run then just as if they were local. You are logged into the remote machine and the output of all commands like mkdir is on that machine.

b) You want to make an uploader? Why don't you just use scp (secure copy)? This program copies files between machines.

scp myfile user@remote_machine:directory/file

so for a file called foo on machine necro we would write:

scp foo mediachicken@necro:/home/mediachicken/foo

I mean inside a C++ Program...

I missed the C++ part... :icon_redface: Well, if you have SSH set up to run without having to type a password (I gave a link in my previous post) then I would assume that you could use "system()" to execute scp or ssh commands. You can use a string variable inside system() so that you can manipulate the command and add flexibility.

Also, there is a tool called Expect which is designed for:

...automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial. Expect is also useful for testing these same applications. And by adding Tk, you can also wrap interactive applications in X11 GUIs.

This sounds perfect for what you've described although I've never actually used it so I can't say much more about it.

http://expect.nist.gov/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.