• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How can I send commands to my desktop?

Deemar

Newbie
I have ConnectBot and right now I'm manually typing commands which I would like to run on my desktop machine remotely. I'd like to create an Android application with a user interface where I can just tap a button and had it run an associated command. I'm assuming I would need to continue doing this via SSH so is there a SSH library for Android which I can use to connect to my desktop? Is there a simpler way of doing this?
 
Am I asking this question properly? All I'm looking for is some simple example code for how to connect using SSH in Android. I can't seem to find any working code anywhere.
 
Hi,

It isn't exactly what you need but you could take a look at this OS project:
premotedroid - PRemoteDroid - Google Project Hosting.

Among other things it allows you to browse files on PC from your Android phone. With little modification it could be executing commands. It is not using ssh though but plain unsecure sockets. It's just a good starting point if you need some working example.
 
That's pretty cool, thanks for posting that I'm looking for something much simpler though, there are a pile of SSH classes out there compatible with Android and there are tutorials/examples included yet I just can't get neither of them to work, they all crash on my emulator and won't run on my phone's version. I've been programming for years and I know Java well, I just can't seem to get these classes to work properly.
 
I've been programming for years and I know Java well, I just can't seem to get these classes to work properly.

So tell us exactly what you've tried and what you were able to diagnose when your tries didn't work. We should be able to kick off from there.
 
So tell us exactly what you've tried and what you were able to diagnose when your tries didn't work. We should be able to kick off from there.

I downloaded the Chilkat library and tried running the example found here. After changing it a bit to work with my package names and import the required libraries I got it to run. However when the emulator starts up and runs the program, it just crashes on the emulated device causing it to force a close.

I downloaded Dropbear and Ganymed but both of those seem to be straight Java implementations, not Android specific. The libraries used in them aren't part of the Android libraries. Same with Jaramiko.

I also tried SSHJ but that also had the same issue with just crashing and forcing closes. Plus I read somewhere it's not supported in Android 4.

I tried JSCH, same issue with forcing closes.

Lastly I tried Trilead but couldn't find any sort of documentation on how to use it.

Anything I can get to compile and run as an example simply forces a close when I run it, nothing else happens. I'm using the correct port on my internal network (192.168.0.194) and the proper username/password written directly into the code. Whenever I use that username/password/IP in a terminal, I can connect via SSH no problem. I can also connect using ConnectBot from my phone and those credentials.
 
I'm confused about your experience with Chilkat. You say you got it to run, but then you say it crashed on startup. Do you just mean you got it to build?

If an application force closes, it's because of an unhandled exception. This exception will be logged into logcat. As you know from being an experienced Java developer, the details of an exception will give you a clue as to what's gone wrong.
 
After long hours spent working on this and code which doesn't work, I'm willing to pay someone to write some simple lines of code that send commands to a desktop via SSH. Very simple. Anyone interested?
 
Back
Top Bottom