How to run DevNullSmtp.jar in background by specifying path to store message and port number? - jar

I need to run the simple SMTP server for sample email communication. I can run the jar and do the configuration from UI, but its tedious to do it everytime. Is there a way to store all the config or run the server in background?

For Windows
java -jar C:\Installed\DevNullSmtp.jar -p 25 -console -s C:\Installed\mailbox -d abc.com,pqr.com
for Linux
nohup java -jar DevNullSmtp.jar -p 2525 -console -s /home/email -d abc.com,pqr.com &
abc.com,pqr.com are the domains from which emails should be received.

Related

Need to Run batch script in UNIX server and display the output through vbscript

I am currently developing the new VBScript to execute the Shell (through Putty software) in UNIX server,
Set shell = WScript.CreateObject("WScript.Shell")
shell.Exec D:\Putty.exe hostname -l username -pw password 1.sh
I am getting connection refused error.
when I run the below command without my script (1.sh)
shell.Exec D:\Putty.exe hostname -l username -pw password
Connection is getting established without any issues.
Also, I just wanted to extract the output, once extracted, the session should get closed automatically.
This doesn't work in putty.exe. Putty has however a dedicated program to do these kind of things, it's called plink.exe - there you can pass commands and read the output just as you would expect, and your example should work just like you specified it.
PuTTY Link: command-line connection utility
Release 0.63
Usage: plink [options] [user#]host [command]
("host" can also be a PuTTY saved session name)
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-v show verbose messages
-load sessname Load settings from saved session
-ssh -telnet -rlogin -raw -serial
force use of a particular protocol
-P port connect to specified port
-l user connect with specified username
-batch disable all interactive prompts
The following options only apply to SSH connections:
-pw passw login with specified password
-D [listen-IP:]listen-port
Dynamic SOCKS-based port forwarding
-L [listen-IP:]listen-port:host:port
Forward local port to remote address
-R [listen-IP:]listen-port:host:port
Forward remote port to local address
-X -x enable / disable X11 forwarding
-A -a enable / disable agent forwarding
-t -T enable / disable pty allocation
-1 -2 force use of particular protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-m file read remote command(s) from file
-s remote command is an SSH subsystem (SSH-2 only)
-N don't start a shell/command (SSH-2 only)
-nc host:port
open tunnel in place of session (SSH-2 only)
-sercfg configuration-string (e.g. 19200,8,n,1,X)
Specify the serial configuration (serial only)

How to deploy my meteor app on Digital Ocean Droplet

I have a a simple meteor 1.0 app that I want to deploy on my Digital Ocean Droplet. I can access this Droplet using ssh.
How can I deploy this app? Is there anything I should install and what are the settings I should use on my Droplet?
I've used arunoda's solution to deploy to my DO Droplet
https://github.com/arunoda/meteor-up
As in the docs after installing the module you'll get the mup command
You can find the detail documentation on how to deploy here
https://meteorhacks.com/deploy-a-meteor-app-into-a-server-or-a-vm.html
All the solution I found were not working well with Ubuntu 10.04. An easy solution is to simply write a bash script to send the code on the remote server and reload the meteor application:
Share a public key between your development environment and the remote server (How tohere)
Create the following script file (myscript.sh) with the following instructions in it (make sure you edit the variables in the header!):
myscript.sh:
#!/bin/bash
#*************** ONLY EDIT THIS PART
SERVER='<SERVER_IP>'
PORT='22'
USERNAME="root"
PROJECT_NAME="<PROJECT_FOLDER_NAME>"
DESTINATION_PATH="</home/any_user/projects>"
ORIGIN_PATH="</home/any_user/projects/project_folder_name>"
COPY_METEOR_PACKAGES=FALSE
#******************
echo ""
echo "Deployment on $USERNAME#$SERVER:$PORT:$DESTINATION_PATH"
echo "Make sure to have a public key on the server! http://www.linuxproblem.org/art_9.html"
echo ""
#copy the files
if $COPY_METEOR_PACKAGES==true; then
echo "Copy packages"
scp -P $PORT -r $ORIGIN_PATH $USERNAME#$SERVER:$DESTINATION_PATH
else
echo "Do not copy packages"
scp -P $PORT -r $ORIGIN_PATH/client $USERNAME#$SERVER:$DESTINATION_PATH
scp -P $PORT -r $ORIGIN_PATH/common $USERNAME#$SERVER:$DESTINATION_PATH
scp -P $PORT -r $ORIGIN_PATH/lib $USERNAME#$SERVER:$DESTINATION_PATH
scp -P $PORT -r $ORIGIN_PATH/public $USERNAME#$SERVER:$DESTINATION_PATH
scp -P $PORT -r $ORIGIN_PATH/server $USERNAME#$SERVER:$DESTINATION_PATH
fi
# reload meteor
ssh $USERNAME#$SERVER bash -c "'
cd $DESTINATION_PATH/$PROJECT_NAME
meteor
exit
'"
Useful info here:
Just run the script using the following command in your development console:
sh myscript.sh
Et voila! When you run this script, it will copy the files and the packages (no need to transfer all the time) to the remote server of your choice using the SSH protocol and it restart the server in case it has crashed (it shouldn't but it was the case for me).

rsync -- command-line for syncing from local to remote over ssh

I'm looking for some assistance please to create a proper command-line for syncing from a local machine to a remote server over ssh.
Here is a draft that is not working.
/usr/bin/rsync --dry-run --delete -arzh /Users/HOME/.0.data/ "--rsh=/Users/HOME/.0.data/.0.emacs/elpa/bin/sshpass -p 'alpine' ssh -p '2222' -l root localhost" -t "cd /var/mobile/Applications/F30B1574-5979-4764-8742-7F9DB2863094/Documents/.0.data && bash --login"
The following command-line successfully logs in to my iphone over ssh via usb. Id like to incorporate that working command-line into something that can be used with rsync, but I need some assistance in that regard.
/Users/HOME/.0.data/.0.emacs/elpa/bin/sshpass -p 'alpine' ssh -p '2222' -l root localhost -t "cd /var/mobile/Applications/F30B1574-5979-4764-8742-7F9DB2863094/Documents/.0.data && bash --login"
For anyone who is interested in leaning how to ssh into an iphone over usb, here is a link that discusses the method: http://iphonedevwiki.net/index.php/SSH_Over_USB
rsync must be installed on both locations. Cydia has an rsync binary that installs on the iPhone. The method of connection with rsync is the same as any regular ssh sever.
Here is a bash script solution (includes --dry-run):
#!/bin/bash
HOST="localhost";
PORT="2222";
USER="root";
PWD="alpine";
SOURCE="/Users/HOME/Desktop/test/";
TARGET="/private/var/mobile/Applications/F30B1574-5979-4764-8742-7F9DB2863094/Documents/test";
SSHPASS="/Users/HOME/.0.data/.0.emacs/elpa/bin/sshpass";
RSYNC="/Users/HOME/.0.data/.0.emacs/elpa/bin/rsync";
$RSYNC --dry-run --progress --delete -arvzh --rsh="$SSHPASS -p $PWD ssh -p $PORT -l $USER" $SOURCE $HOST:$TARGET
For an example of how to use rsync in conjunction with Emacs, see the following thread: https://emacs.stackexchange.com/a/5844/2287

Permission denied to use sftp -b batch file

I can log in to my remote using ssh/sftp (without the -b option)
sftp root#192.168.7.2
But when I try
sftp -b commands.tmp root#192.168.7.2
I get
Permission denied (publickey,password).
Couldn't read packet: Connection reset by peer
Commands.tmp looks like this
ls
exit
Anything I am missing here ?
I used shhpass to write the password no interactive and I needed to add -oBatchMode=no
sshpass -p PASSWORD sftp -v -oBatchMode=no -b FILE USER#SERVER
If you are authentication with a password or an encrypted private key, you cannot use the -b with plain sftp. The sftp man says:
Since it lacks user interaction it should be used in conjunction with non-interactive authentication
You can for example use a passphrase-less private key together with the -b.
If you want to use password authentication, you need to use workarounds like sshpass. See:
How to run the sftp command with a password from Bash script?
This worked for me
sshpass -p 'PASSWORDSTRING' sftp -v -oBatchMode=no -b deploy/production username#ipaddress
production file
put -rp /from-directory /to-directory

How to gracefully reload a spawn-fcgi script for nginx

My stack is nginx that runs python web.py fast-cgi scripts using spawn-fcgi. I am using runit to keep the process alive as a Daemon. I am using unix sockets fior the spawed-fcgi.
The below is my runit script called myserver in /etc/sv/myserver with the run file in /etc/sv/myserver/run.
exec spawn-fcgi -n -d /home/ubuntu/Servers/rtbTest/ -s /tmp/nginx9002.socket -u www-data -f /home/ubuntu/Servers/rtbTest/index.py >> /var/log/mylog.sys.log 2>&1
I need to push changes to the sripts to the production servers. I use paramiko to ssh into the box and update the index.py script.
My question is this, how do I gracefully reload the index.py using best practice to update to the new code.
Do I use:
sudo /etc/init.d/nginx reload
Do I restart the the runit script:
sudo sv start myserver
Or do I use both:
sudo /etc/init.d/nginx reload
sudo sv start myserver
Or none of the above?
Basically you have to re-start the process that's loaded your Python script. This is spawn-cgi and not nginx itself. nginx only communicates with spawn-cgi via the Unix socket and will happily re-connect if the connection is lost due to a restart of the spawn-cgi process.
Therefore I'd suggest a simple sudo sv restart myserver. No need to re-start/re-load nginx itself.

Resources