erlang shell can't ping pong in same pc - erl

when I use erl open multi nodes,
and then I start erl like this:
erl -sname test1
erl -sname test2
And then, I logon the two shells and test ping each other,
but can't ping pong.
net_adm:ping(test2).
Anywhere wrong? Does somebody know?
The detail message info is:
enter image description here

Once you issued erl -sname [some_name] check inside your shell what the name of the node is , using the method node/0:
erl --sname test1
>>node()
In case you do have another name try with net_adm:ping('test1#[full_name]').

Related

How to run a cmd line application in PowerShell

I want to run this command
telnet -a servername port
-CASServer V2.00 connection from 0.0.0.0 [] Diag mode only
status
Clients: Static 0/50 Dynamic 19/50
Application1: 1 0xcb4388 hSock(0x2d4)
Application2: 0 0
OK
I am basically only interested in "Dynamic 19/50". If possible, I'd like to get this information from PowerShell
The PowerShell script at http://community.spiceworks.com/scripts/show/1887-get-telnet-telnet-to-a-device-and-issue-commands might work for what your're trying to accomplish. It creates a PowerShell function called 'Get-Telnet'; it can establish a telnet connection and send a series of commands.
Your usage would be something like:
Get-Telnet -RemoteHost [servername] -Port [port] -OutputhPath results.txt
After which you could parse the data you need (e.g., the 'Clients' line) from 'results.txt'.
In order to run a cmd line application in PowerShell, specifically the telnet command, you first need to install telnet.
Use this command, with admin privs:
pkgmgr /iu:"TelnetClient"
After installing you can run your telnet -a servername port command in PowerShell:
Running a command line application (telnet) in PowerShell
I am not positive on what exact command line application you are trying to run. However here is an example of running a command line application in powershell.
&'C:\Program Files\gs\gs9.14\bin\gswin64c.exe' -sDEVICE=tiffg4 -dBATCH -dNOPAUSE -q -r600 "-sOutputFile=$OutputFullDirectory" "$InputPath"
This would be ghostscript however the key is using the & symbol to call the command line and then enter in the path to the exe file you want to run then you can pump in the parameters. Hope this helps lead you in the right direction

Perl Debugger: Filehandle as Input

I have this problem:
I need to control the perl-debugger from an external script.
By research I found out about various solutions, but I don't understand them.
I failed to properly set up the RemotePort option (editing ".perldb"), which was the first I tried, and found no useful information on providing a filehandle from which the debugger would get its input (by somehow setting #cmdfhs)
I found both options over here: http://search.cpan.org/~nwclark/perl-5.8.6/lib/perl5db.pl
It would be nice if you could tell me how to provide the filehandle from which the debugger gets its input, or if you know a link where this is explained?
Here's a simple example setting it up using RemotePort, which seemed easier to me:
The trick to using RemotePort is that you have to have someone listening on the remote end BEFORE you launch the script to be debugged.
As soon as you launch your script with -d Perl will attempt to connect to RemotePort. So you have to make sure the initial connection succeeds by having someone listening there beforehand.
Here I assume some Linux/Unix variant, which has the netcat utility installed. We use netcat to wait for incoming connections in this example, but you can use anything else you wish too which is able to create a service port and shuffle data between that and the current TTY:
In terminal 1:
# Use netcat to listen for incoming connections on port 9999
> nc -l -p 9999
In terminal 2:
# Start perl with -d and request a RemotePort connection
> PERLDB_OPTS=RemotePort=127.0.0.1:9999 perl -d my_script.pl
As soon as you do that in terminal 1 you will see something like this:
Loading DB routines from perl5db.pl version 1.39_10
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(my_script.pl:4):
DB<1>
There you go..debug away.
Devel::Trepan is a gdb-like debugger. Although it has remote control, you can also run it at the outset with the option --command which will "source" (in the gdb-sense) or run a series of debugger commands.
To go into remote control, either start the debugger using the --server option or inside the debugger use the "server" command once inside the debugger.
See Options for a list of options you can give at the outset.

Perl Try::Tiny stuck in Loop

I am using a Try::Tiny statement to avoid failing if I can't rsh to a host. But it seems that the rsh is getting retried indefinitely.
In this particular case, Host2 went down, and the code just repeatedly attempted to contact Host2 until I cancelled execution with CTRL+C. What I am expecting is for Host2 rsh command to fail, and the script to move on to Host3.
Any idea of why this doesn't work and how I could do it differently?
#Win_Clients = ("Host1","Host2","Host2");
foreach $Win_Client (#Win_Clients){
try {
#mem= rsh ($Win_Client, "wmic memphysical get MaxCapacity");
print "host=$Win_Client, mem=$mem";
};
}
I think your best solution would be to not use rsh to run wmic, and instead use the built in remote access mechanism /node
C:\Users\ME>wmic /node:localhost memphysical get MaxCapacity
MaxCapacity
4194304
C:\Users\ME>wmic /node:narf memphysical get MaxCapacity
Node - narf
ERROR:
Description = The RPC server is unavailable.
And then you won't need to do anything like running rsh or try. You can simply trap error levels in the 'usual way'. ($? in your perl client)
C:\Users\ME>wmic /?
[global switches] <command>
The following global switches are available:
/NAMESPACE Path for the namespace the alias operate against.
/ROLE Path for the role containing the alias definitions.
/NODE Servers the alias will operate against.

starting C executable in raspbian on startup

I'm using raspbian on a raspberry pi and I need to start a program on startup. What is the easiest way to do this? A bash script?
normally I run the following code in terminal:
../simple/./simple_run 12345
the executable has an input for 12345
Can someone step me through on how to do this?
Could you call your script at /etc/rc.local
If this file doesn't exist, create this:
#!/bin/sh -e
#
/.../myScript.sh
replace /.../myScript.sh by your script call... use full path.
Only one question... your script will be executed with "root" user... take care!

Rails, Deploying With Capistrano to a VPS on Unicorn

I need help debugging the following issue. It's my first time deploying, and I haven't been able to come up with the solution.
* 2012-12-05 18:37:44 executing `deploy:start'
* executing "/etc/init.d/unicorn_blog start"
executing command
/etc/init.d/unicorn_blog: 24: kill: No such process
master failed to start, check stderr log for details
Here's the stderr
/.../unicorn/socket_helper.rb:140:in `initialize': Address already in use - /tmp/unicorn.my_app.sock (Errno::EADDRINUSE)
It looks like you have a zombie Unicorn process running with a PID different from the one that was recorded by init.d. I would try running $ ps aux | grep unicorn to find the zombie process, then kill it.
Unsure how it works, but the following solution actually worked.
lsof /tmp/unicorn.my_app.socket
lists the pids
kill -9 pid
(replace 'pid' with one of those listed)
Then cap deploy:start from the local terminal.
source: Unicorn/Nginx process missing, socket open
I had to
sudo rm /tmp/unicorn.my_app.sock
and
sudo /etc/init.d/unicorn_myapp start
I got same error, and i fixed as below:
SSH to server where your project deploy to, and run these command
ps -ef | grep unicorn => list pid of unicorn. Find your process id of unocorn master.
Replace pid on "unicorn.my_app.sock" with above pid.
Try to deploy again with capistrano.