LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash scrip running on remote server (https://www.linuxquestions.org/questions/linux-newbie-8/bash-scrip-running-on-remote-server-4175536675/)

hassan hashmi 03-13-2015 05:52 PM

bash scrip running on remote server
 
This is my script and the syntax to run this script is give ip and next will be the file or script you want to perform on remote server



#!/bin/bash

# The private key used to identify this machine
IDENTITY_KEY=/home/adnew.pem

syntax()
{
echo "Syntax: Ec2.sh server_ip scriptFile]"
echo "For example: ./Ec2.sh server_ip scriptFile"
exit 1
}

if [ $# -ne 2 ]
then
echo not enough arguments
syntax
fi


echo "Running script $2 on $1"
ssh -ttq -i $IDENTITY_KEY ec2-user@$1 sudo -i 'bash -s' < $2
exit
exit
echo "Done"



on script file i have give for testing

touch /root/test
ls /root/test
exit
exit

it makes the file but do not show the ls output by giving error


tcgetattr: Inappropriate ioctl for device

exit


what I have to do ??

veerain 03-14-2015 12:23 AM

Quote:

ssh -ttq -i $IDENTITY_KEY ec2-user@$1 sudo -i 'bash -s' < $2
Try passing just one -t option like this:

Code:

ssh -tq -i $IDENTITY_KEY ec2-user@$1 sudo -i 'bash -s' < $2
As multiple -t option causes local tty allocation. Read man page of ssh.


All times are GMT -5. The time now is 10:31 PM.