0

This is my batch script. I wanted to automate restart of the mysql

cd G:\My Drive\TCL
G:
ssh -i themedcreations.pem ec2-user@ec2-3-16-127-158.us-east-2.compute.amazonaws.com
sudo su
service mysqld restart
Pause

The script is okay if I manually input the lines in cmd. I was hoping the batch file could run itself till the end, but it stops after running the ssh -i line, afterwards it requires manual input.

What went wrong? I am completely new to batch scripting. I tried timeout or wait. They all didn't work.

  • Are you expecting "sudo su" and the following commands to run on the remote system? – Kenster Mar 07 '20 at 20:40
  • Yes. But the cmd prompt didn't run sudo su. they had to be manually typed in –  Mar 07 '20 at 20:46
  • There is no `sudo` command in Windows. The cmd script runs on your host windows system, not the remote machine you connect to with ssh. – jwdonahue Mar 08 '20 at 00:17

1 Answers1

-1

Use the -n flag and see if it solves your problem.

example

ssh -n -i themedcreations.pem ec2-user@ec2-3-16-127-158.us-east-2.compute.amazonaws.com
Vasu Inukollu
  • 120
  • 1
  • 3
  • 10