Does anyone know of a JS-based terminal client? Either something that initiates an SSH connection with a remote host or even something that simply communicates with a remote PHP script to execute commands and retrieve output. Does such a thing exist?
Check Anyterm, it uses a XmlHttpRequest channel to communicate with a daemon that uses a pseudo-terminal to communicate with a shell or other application.
http://www.masswerk.at/termlib/ looks interesting as a base.
http://sourceforge.net/projects/jsterminal
but you'd have to write your own commands to connect with the host
Shell in a box could be used also with a small Asus EEE-PC:
http://code.google.com/p/shellinabox/
It works great also for virtual machines in a cloud.
So far JSDom Shell is the only thing I have found, which seems relatively barebones but practical. If there are any other more substantial options, feel free to share!
Related
I'm looking for a way to read/write a PC's serial com port using PHP/IIS on Windows 10. I've experimented for a few days now, but every attempt failed.
I tried to use php_dio.php, only to find out this dll misses some essential implementation on Windows. Through StackOverflow I also read that it would impossible for PHP on Windows to do this.
I can use Powershell on Windows to perform the tasks I want using scripts, but I'm not able to gets it output. Also, I fail to start this from PHP using exec or shell_exec.
So, at the moment, I'm stuck. My goal is to create a PHP-file which is able to receive requests from the web. That request would than be translated into a command which I would send to a device which is connected on my com-port. The response on the com-port would then be sent back to the server which did the request. It's just simple serial I/O, like 9600 bd, No parity etc. The setup works, but like I said, every attempt to use PHP to access the com port fails.
Is there a way?
Suggestions are appreciated.
Thanks.
Tried php_dio, exec, shell_exec
I am using the following js plugin which allows me to use WebSockets on android and iOS with apps written in html5 (via phonegap in my case).
https://github.com/FreakDev/PhoneGap-Android-HTML5-WebSocket
What else do I need in order to use a websocket?
I have a basic server with bluehost that has PHP and MySQL installed.. What am I going to need to do?
First you can use a library like this one:
http://code.google.com/p/phpwebsocket/
Second, your host must let you create sockets. This mean PHP must have php_sockets.dll (Win) or sockets.so (Linux) extension enabled and a forwarded port from your server.
Also you need to run your php from commend line or somehow keep it alive for ever.
It is just like creating a normal socket in PHP.
*Edit:
WebSockets are just some sort of normal sockets. In websocket you can connect to a endpoint which is listening for connections and then communicate with it. Just like normal sockets but with simple differences in protocol and more limitations. For doing so you need a script or application to run for ever and handle all connections from webpages. But a php file will end just after request ended. For keeping a php file running for ever you need to run it from commend line which mean you need to have shell access, or you can use this code to run your php script for ever: (But you must think about a mechanism to call it only once)
ignore_user_abort(true);
ini_set('max_execution_time', 0);
set_time_limit(0);
You can test. If your application fail with error messages about not knowing a function like socket_connect or socket_bind then you don't have socket extension for php.
Here is phpwebsocket files for download:
http://phpwebsocket.googlecode.com/svn/trunk/%20phpwebsocket/
There is an example there too.
As "Tom van der Woerdt" said PHP is not designed for doing socket programming. Go for a non-scripting language and use a dedicated server or at least a vps for opening and managing sockets.
I'm working on making a website/web application that displays images every 5 or so minutes, kinda like a webcam. The images are uploaded to an SFTP server. How can I access those from the web? Does anyone have any recommendations for what to use as well? Right now I'm looking at PHP but have checked out javascript and ruby as well. Only the application needs to ssh to a predetermined place, not the users.
I was suggested by a friend to use rsync and setup passwordless ssh. Anyone ever do this? or is this a bad idea?
If the application is the only thing that needs to SSH then you can rule out javascript immediately. It's predominately a client-side language in these environments.
You may like at Net::SSH ruby library, or I'm sure there's a php equivalent. I have used Net:SSH and it's fairly straight forward.
You need to write a server-side script that connects to the SFTP server and forwards the image to the client.
cURL has SFTP support.
PHP supports SFTP. You need to install ssh2 extension,
http://www.php.net/manual/en/book.ssh2.php
I need to access COM port (console) via script to access our DSL modem.
It should access in such a way that I can read all the messages printed on the console and i should also send commands to the console via script .
Please let me know if it is possible in TCL or php .
Platform : Windows XP.
Also is there any way I can access the com port through script and console software such as teraterm simultaneously ?
Regards,
Mithun
It is possible to use TCL to access a serial (COM) port using the standard TCL input and output commands. The main ones that you need to look at are the open and fconfigure commands. A google search for 'tcl open com1' will bring back lots of examples.
One thing worth noting is that the open and fconfigure commands changed in recent versions of TCL, TCL 8.5 I think, so depending on the version of TCL and age of the example some rework might be needed.
You just need to open the com1: device and fconfigure it to use the communications settings that the other side expects. For example:
set fd [open "com1:" r+]
fconfigure $fd -mode 9600,n,8,1
Be aware that it can be messy to use event-driven IO with serial ports on all platforms.
Sounds like a job for Expect.
I was wondering, whether knockd http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki would be a good was to be able to restart apache without logging into ssh. But my programming question was whether there is a way to send tcp/udp packages via PHP so I can knock via a webclient.
I am aware that this is not the safest way of doing it, but I will only want to do things like update the svn, restart apache without having any passwords in it like with using ssh to do that.
You may use fsockopen() functions... but what you are doing(and the way you are doing it) is very risky from a security standpoit.. as it had been said, ssh is the way:)
If you really want to restart the apache server by using remote access (non-ssh) you can create a small php-daemon, that just watches for a specific file,(ex: /tmp/restart.apache) and when that file appears run exec("/etc/init.d/apache restart") (or whatever the command is for your distribution). This daemon should run as root... and the thing is that the whole security thing is up to you this way, you have to make sure this cannot get arbitrarly executed...
Your portknock ideea... a simple port scanner may restart your apache by mistake:) portknock is recommented to be used in conjunction with a ssh auth , not directly with apache:)
Seriously, you do not want to do what your trying to do.
You should look into calling your remote server through some sort of secure protocol, like SSH. And on the client side, have a small PHP utility application/script that executes remote SSH commands (preferably with a keyfile only based authentication mechanism).
Why not have a PHP script that calls "svn update"? As long as the files are writeable by the user Apache runs as, it works great. Just hit that URL to update the website
For SVN you have whole PHP api, try search SVN on php.net