Android Question Initiate a program on a remote

Stephenz43

Member
Licensed User
Longtime User
Hello

I need a bit of advice. is it possible to initiate a program on a remote system by using a Android Mobile device? I would like to create a b4a android app that send a instruction to the remote system to start a specific application. I am not sure how to start and what approach to take.

Any advice would be appreciated
Stephen
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Yes, it is possible. If that answer is too vague, it is because we need a more specific description of what you want to do.

--- Jem
 
Upvote 0

Stephenz43

Member
Licensed User
Longtime User
Hi and thanks for the response

Presently I have a few apps that connect to MS sqlserver and read data...however,

what I would like to figure out is how to start a specific app that resides on the remote MS system. Just a a small android app that starts the remote MS desktop exe whenever I care to.
 
Upvote 0

HotShoe

Well-Known Member
Licensed User
Longtime User
You can use b4j, php, ruby, or whatever to create the server interface on the pc. From there it depends on the application that you want to run. If it is web aware, you can communicate with it directly, otherwise it is a matter of issuing a shell command in whatever you use on the pc side to start the program. You would need to create the interface on the pc side and possibly a data delivery means as well.

--- Jem
 
Upvote 0

Stephenz43

Member
Licensed User
Longtime User
You can use b4j, php, ruby, or whatever to create the server interface on the pc. From there it depends on the application that you want to run. If it is web aware, you can communicate with it directly, otherwise it is a matter of issuing a shell command in whatever you use on the pc side to start the program. You would need to create the interface on the pc side and possibly a data delivery means as well.

--- Jem
I'm not following, could you point me to something to get started

~steve
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Steve,
I believe that HotShoe well summarized all the elements to take in account.
Here I try to be more detailed only to help you better focusing on how to reach your goal.

Fundamentally your architecture is based on three elements:
1. a server (i.e. the PC running the existing DB-aware programs); from your writing I suppose that's a Windows machine
2. a communication medium (Internet, LAN, WiFi, Bluetooth, USB..)
3. a client (i.e. your Android device).

Point 3 is very easy; just design a nice UI and let the user tap a button, select from a listview or any other visual control to send the appropriate command to the server.

Point 2 depends on the way you're going to use the system and that will influence what you've to deploy on the server.
Assuming the Internet as the medium, you may want to have a look at the HttpUtils2 library in order to send commands through the use of GET or PUT to a listening server.
This mandates the server to be publicly reachable (i.e. assigned a public IP, eventualy using services like DynDNS).
On the server you may deploy a traditional webserver+PHP interpreter like Apache+PHP or IIS+PHP where the role of the PHP would be that of listening for commands from the client and executing the desidered local (to the server) program by means of a shell instance.
Otherwise you may easily write some code with the superb B4J (so to do everything in BASIC) to do essentially the same thing. You may find a lot of complete examples in the B4J dedicated area on this excellent forum.

Point 1, as said, depends on point 2 above. Essentially you will deploy a "listening box" and issue shell commands to execute local programs.
As HotShoe suggested, if those programs are already web-aware you may want to directly interface with them so all the picture gets simplified.

udg
 
Upvote 0

Stephenz43

Member
Licensed User
Longtime User
I am getting humbled on this topic.
I decided to search the web for a client/server that would accomplish what I needed and found Remote Launcher http://owtroid.com/remotelauncher/mediawiki/index.php. It works great but I need the client to be alot more robust. So...

The client.... Is there a example of a android client app sending the instruction to execute a program

The server... Is there a b4j example of listening to a port on the windows machine and executing the program ex( notepad.exe )

httpUtils2.. a mention of put and get was made. Is there a example

Help
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Steve,

have a look at this thread. You will find a working example of a B4A client that sends text (so "command requests" as per your requirement) to a B4J server where an handler receives those commands.
To add the last element missing from your request, see here. That shows how to shell to an external program residing on the same server PC where the B4J server program is running.
Try to put the pieces together yourself then come back with any further question.

udg

Edit: I forgot to write you can disregard (i.e. delete) any reference to file-related stuff in the demos and that you can limit the example scope to your LAN configuring the proper IP address in the global vars.
 
Last edited:
Upvote 0

Stephenz43

Member
Licensed User
Longtime User
Hey udg

The Server :
so far I have got the server running on a network machine..I can see it by 12.0.0.1, by its internal ip and the external ip... A few words to the wise :
1. make sure you set #MergeLibraries: True ..if set to false, the jar file will not install without the IDE
2. make sure the router port you want to use is enabled
3. make sure the firewall is correctly set
4. make sure the anti-virus is correctly set






Thanks
 
Last edited:
  • Like
Reactions: udg
Upvote 0

Troberg

Well-Known Member
Licensed User
Longtime User
Of course, in such issues, security is a concern. Can you trust the mobile device, and can you trust the connection. If you can, just make a tiny shell which sends telnet commands on button pushes (or, if you are lazy and no one else is going to use it, just download a telnet client for your device). If not, you'll probably want to build a server service to run on the server, which has security and only allows specific programs to be launched.
 
Upvote 0
Top