Okay, I know my title is a bit obscure but let me explain what I did and how I failed to accomplish what I wanted to do.
First off, security is not a my concern at this moment. Once I get it working I will implement an authentication schema to protect my setup.
I want my windows machine at home, to ftp/scp a batch file from a Linux server on the cloud (A VPS with non-root user playing ftp/scp server role) and run it as soon as it completes downloading it.
I setup a non-privileged (read as non-root) account on my vps. I generated a public/private key pair. From my windows PC, using the key-pair I was able to login to my VPS without needing a password. Using the same key-pair, I was able to download a file from my VPS onto windows machine.
I have a batch file that I scheduled to run every 3 minutes using the windows' internal task scheduler. Batch file does something like this :
scp remote-server:/home/user1/job.bat .
job.bat > outfile.txt
scp outfile.txt user1@remote-server:/home/user1/outfile.txt
echo "rem done" > job.bat
scp job.bat user1@remote-server:/home/user1/job.bat
last two lines are there to protect against unintentional run of the same batch twice.
when it runs, if pulls the batch file from the remote-server but fails to execute it as the subsequent line and the batch file dies without going any further than the first line.
The reason I am looking for something like this is two fold. 1) when I can I access to my laptop, using VNC, but sometimes, it goes unresponsive and I have no other way to take back control but killing VNC process and restarting from the command line;m 2) when I am bandwidth limited, I'd like to run a nircmd command to take a screenshot and send it to me via scp, so that I can follow up, what's going on at home.
Can someone shed a light, why I am in this shape, i.e., why my batch file gets stuck after first line ? More importantly, how can I fix this ?