Problem with Sudo inside a here document


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problem with Sudo inside a here document
# 1  
Old 11-12-2010
Problem with Sudo inside a here document

Have a sudo statement inside of a here document. It prompts me for a password, but doesnt wait for me to enter my password. Is there a way I can use the command without sudo or anyway that I can enter the password correctly?

Eg :
Code:
while read  remotehost
do
  ssh -t $2@$remotehost  <<REMOTE

   ls /path/to/file/ | while read line
     do
              sudo  vserver \$line enter
              echo "\$line Hello world"
      done

REMOTE
done < "$remotehostlist"

This asks for password for the following line sudo vserver $line enter. But it doesnt wait for me to enter password. Also if I type something it appears in cleartext.

Please help!!

Moderator's Comments:
Mod Comment Double post. Continue here

Last edited by Scott; 11-12-2010 at 04:31 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with here-document not seeing delimiter

System is Oracle Linux 6 (derivative of RHEL) Given this script (copied from vi with line numbering for reference) 1 #!/bin/sh 2 ORAENV_ASK=NO 3 echo "*****************************************************" 4 echo "** Stop all databases and listener" 5 echo... (6 Replies)
Discussion started by: edstevens
6 Replies

2. HP-UX

Problem using sudo with NOPASSWD

I need to configure access for a user in an HP-UX to : 1) use certain commands and 2) login as another user as a sudo. These have to be done WITHOUT the user needing to enter a password. However, after I enter the lines using visudo, there is a prompt for a password when the user... (3 Replies)
Discussion started by: aigini82
3 Replies

3. Shell Programming and Scripting

ssh uses here-document problem

I try to ssh uses bash script in here-document like this. ssh root@$SERVER <<EOF if ; then service httpd start fi exit EOF But got an error below. maybe the if command causes the problem. Thanks for help. (2 Replies)
Discussion started by: muffle
2 Replies

4. Shell Programming and Scripting

sudo inside a here document not working

Have a sudo statement inside of a here document. It prompts me for a password, but doesnt wait for me to enter my password. Is there a way I can use the command without sudo or anyway that I can enter the password correctly? Eg : while read remotehost do ssh -t $2@$remotehost <<REMOTE... (13 Replies)
Discussion started by: mnanavati
13 Replies

5. Shell Programming and Scripting

Here document inside a here document?

Can we use a here document inside a here document? Something like this ssh user@remotehost << REMOTE sudo vserver vsernamename enter << VSERVER perform actions on vserver. VSERVER REMOTE (6 Replies)
Discussion started by: mnanavati
6 Replies

6. Solaris

Problem with password expire and sudo.

Hi, I have a small problem that I need to address regarding the password expiration for a number of different oracle accounts. Currently I have the MAXWEEKS set to 12 in the /etc/default/passwd file for all accounts. I also have sudo installed on the server and users access the oracle accounts... (2 Replies)
Discussion started by: sparcman
2 Replies

7. Linux

Sudo Problem?

Hi I wanted to add a group using 1 id which is not root but has some sudo privileges. test@test>sudo -l gives this (root) NOPASSWD: /usr/bin/passwd, /usr/sbin/useradd, /usr/sbin/usermod, /usr/sbin/userdel, /usr/bin/tee, /usr/bin/grep, /bin/grep, /usr/bin/chmod, /bin/chmod, /usr/bin/echo,... (1 Reply)
Discussion started by: datkan
1 Replies

8. UNIX for Advanced & Expert Users

Sudo command problem

Hi All, I am tring to redirect mails comming to my user id to a script. In other word trigger a script when a mail comes to my user id. Actually , Admin team has done all this to me previously. in my script i am doing like /usr/local/bin/sudo -u parbrxs /export/home/parbrxs/bin/parbrxs.sh... (4 Replies)
Discussion started by: mindtee_abhi
4 Replies

9. Shell Programming and Scripting

sudo command is not working inside a script when placed in cron

Hi All, i have a cron entry like 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /amex/sssmonitor/dss_chk.ksh and the script is like #!/bin/ksh file=`uname -n` > /sunmast/projects/oasis/COREDEV/Dss$file.log > /tmp/output_sss today=`date` varb=`ps -ef | grep... (5 Replies)
Discussion started by: usha rao
5 Replies

10. Shell Programming and Scripting

problem with sudo su and .sh script

here is my script: #!/bin/sh cd /Users/a echo "what is the name of the file u want?" read var1 var1=$var1... (1 Reply)
Discussion started by: cleansing_flame
1 Replies
Login or Register to Ask a Question