title: sudo sorry, you must have a tty to run sudo
body: <p>I have written a bash script that goes to each machine and runs set of command. I am using the user iis that has sudo privlidges on that machine. However, when i run the sudo yum command i get sudo: sorry, you must have a tty to run sudo.</p>
  
  <p>Not sure what is wrong ? I am using the -t command to force but it would still not work</p>
  
  <p>bash script </p>
  
  <pre><code>#!/bin/bash
  INPUT=ccidetails.csv
  OLDIFS=$IFS
  IFS=,
  [ ! -f $INPUT ] &amp;&amp; { echo "$INPUT file not found"; exit 99; }
  while read privateip password
  do
  echo $privateip
  scp /home/Data/Test.c iis@$privateip:/tmp
  sshpass -p$password &lt;/dev/null ssh -t -o "StrictHostKeyChecking no" iis@$privateip "
  
  hostname
  cd /tmp
  gcc Test.c -o TEST
  ./TEST
  sudo yum -y update glibc
  gcc Test.c -o TEST
  ./TEST
  exit
  
  " &gt;&gt; output.txt
  
  done &lt; $INPUT
  IFS=$OLDIFS
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>sudo: sorry, you must have a tty to run sudo
  </code></pre>