Is there a way to echo on a UNIX terminal the output of a local server running a web-socket? - debugging

I am running some code that implements a web-socket server locally.
I'd like to echo the output of it on a Unix Terminal to verify whether it works correctly.
The curl command page does not seem to state the support the web-socket protocol.
Are you aware of any other UNIX commend that does so?

My tool websocat supports it (and WebSocket server as well).
Other alternatives include multiple tools named "wscat" (1,2,3), "ws" and maybe others.

Related

Android studio not running .sh script with Jsch

Whenever I try to execute a sh script via Jsh nothing happens , however when I execute it through a normal ssh session it works fine , I haven't been able to get a single sh file to work/run regardless of the contents of the sh file.
I have tried
channelssh.setCommand("/home/exiatron00/Desktop/bash test.sh");
channelssh.setCommand("/home/exiatron00/Desktop/./test.sh");
channelssh.setCommand("/home/exiatron00/Desktop/test.sh");
I don't see anything wrong with your command, so I would have to assume it's your setup.
Are you sure you're even logging into your server? I would check your last logs to make sure you are even connecting.
Are you on the same network as the machine you're attempting to connect to? If you aren't on wifi I would assume your machine is hidden behind a NAT.

Is it possible to restart the server using WinSCP?

I transferred the files from my local computer to the remote directory using WinSCP, but I'm curious if I can restart/reboot the server using the same application or i need to do that using PuTTY.
I don’t think you can. WinSCP is a SFTP client, SFTP its a subsystem of SSH, but that does not mean that you can achieve everything you can do with SSH.
Here’s a complete list of commands supported by the SFTP protocol -> https://www.ssh.com/ssh/sftp/#sec-SFTP-Protocol
As you can see there’s no such ‘reboot’ instruction nor anything similar.
EDIT
As other answer says, WinSCP has the ability to issue remote commands https://winscp.net/eng/docs/remote_command
So you can do Commands > Open Terminal and issue a reboot
WinSCP has Console window, where you can execute most shell commands. The only limitation is that the command must not require terminal emulation. What command like reboot typically do not.
Short answer: you need putty to do it.
Long answer: If you know what you are doing you could have a watch of some kind and reboot the server if you copy a special file (via WinSCP) to the server, I would strongly advise against this.
If you use putty to do this you should be aware that the system user root is most likely forbidden to log in via ssh directly. So you have to use putty with some other user and use su/sudo to reboot.
To reboot a linux server
putty
sudo reboot

Sending data through Telnet-established connection on windows command line

I have connected to an outside server using telnet on windows cmd. I have a program written in Ruby running on my local machine whose output needs to be passed as a command in the server running. How do I go about with it?
You can't. A telnet connection is pretty easy to do in Ruby though, just make your own connection.

Perl + Apache + CGI

How do I run perl script from local host?
I have installed Apache 2.2 and Active Perl 5.16.3.
I am able to run the perl scrip from command prompt.
But since i am dealing with web application, i want it to be run from localhost.
However, I am getting the following error in the browser
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please help me out!
Your problem is probably related to the configuration of Apache. (It may be Apache that needs configuring for .cgi scripts) - If this is the case then you can find good info on this here:
http://www.perlmonks.org/?node_id=44536
http://www.cgi101.com/book/connect/winxp.html
http://www.editrocket.com/articles/perl_apache_windows.html
There is usually a host of things that you need to do to get it working. Following a good HOWTO to make sure that everything is installed and configured correctly will usually get you going to execute scripts on your local Windows machine.
You could run cgi script from web browser. CGI means that it should send a HTML header before sending any output to the server (which is going to send it back to the browser).
http://perldoc.perl.org/CGI.html#NAME
http://www.cs.tut.fi/~jkorpela/perl/cgi.html
Like this:
use CGI; # load CGI routines
$q = CGI->new;
print $q->header; # create the HTTP header
print $q->start_html('hello world'); # start the HTML
### your script logic goes here
print $q->end_html; # end the HTML
Of course, CGI is outdated, for new development you should use some mmore recent framwork like: Dancer, Mojolicious, ...
if someone is looking for an answer in year 2017 then follow this on windows 2010 machine.
Download Strawberry perl from perl site
Install in default directory.C:\Strawberry
Download Apache from https://httpd.apache.org/download.cgi#apache24
Once you successfully get apache server running then
Place your perl scripts in your Apache24/cgi-bin/ folder.
firstline of your perl script should point to path where perl is installed for my case it is #!C:/Strawberry/perl/bin/perl.exe
you should change your path according your installation folder
Filename - first.pl
#!C:/Strawberry/perl/bin/perl.exe
print "Content-type: text/html\n\n";
print "Hello, World.";
Now you can run your script from browser http://localhost/cgi-bin/first.pl

Run script on remote machine via telnet (not SSH)

I need to somehow run a script which resides on a remote machine running Ubuntu.
SSH or any other connection type that requires complex encryption is not possible.
The client that will connect to the remote machine is only capable of opening a port and sending and receiving strings.
Can anyone tell me how to do this?
Why is your remote Ubuntu machine "not natively capable of SSH". That's nonsense.
But if you want a solution, use expect - it can run ftp/telnet or any other terminal-based application. It can react to different input, and type in a password.
There are python and perl-based packages that also do this.

Resources