[SOLVED] Running a script remotely with a sudo id | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

[SOLVED] Running a script remotely with a sudo id

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-10-2012
arjunprathap arjunprathap is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 11 February 2013, 11:02 AM EST
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
Java [SOLVED] Running a script remotely with a sudo id

I'm trying to run the script /home/a501007/ListQAwarfile.sh using a sudo id intkwss1 in the machine asappl11dev

Wrapper Script : main.sh

ssh -t asappl11dev sudo -H -u intkwss1 bash < /home/a501007/ListQAwarfile.sh


Script : /home/a501007/ListQAwarfile.sh

Code:
#!/bin/bash
inp_dir=/opt/is/apps/intkwsiss1/apps/
export inp_dir;
outfile=/home/a501007/tempout
export outfile;
qainpwarlist=/home/a501007/qainpwarfilelist.txt
export qainpwarlist;
qaoutwarlist=/home/a501007/qaoutwarfilelist.txt
while read line;
do
tcs_name=`echo "$line" | awk '{ print $1 }'`
war_name=`echo "$line" | awk '{ print $2 }'`
ls -lrt $inp_dir$tcs_name/$war_name*.war >> $outfile
done < $qainpwarlist 
mv $outfile $qaoutwarlist

I'm getting teh following error when i run the wrapper script ( main.sh )

ioappl01uat.fmrco.com:/home/a501007% main.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
a501007@asappl11dev's password:
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
bash: line 17: syntax error near unexpected token `done'
'ash: line 17: `done < $qainpwarlist

Any Idea what am i missing ?????
Moderator's Comments:
Please use code tags

Last edited by jim mcnamara; 09-10-2012 at 01:16 PM..
Sponsored Links
    #2  
Old 09-10-2012
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 30 October 2014, 7:23 AM EDT
Location: NM
Posts: 10,252
Thanks: 284
Thanked 803 Times in 747 Posts
It is trying to get a password from the current terminal - your keyboard. You need to install ssh keys generated on the local box onto the remote box.

how to:
ssh-keygen: password-less SSH login
Sponsored Links
    #3  
Old 09-11-2012
arjunprathap arjunprathap is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 11 February 2013, 11:02 AM EST
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
CPU & Memory

@ Jim ..

The issue is nothing to do with the ssh keys .. if i give the password to connect to the remote server, its throwing error in the while loop ...
    #4  
Old 09-11-2012
priyak priyak is offline
Registered User
 
Join Date: Aug 2012
Last Activity: 28 January 2013, 2:48 AM EST
Location: Tamil Nadu
Posts: 16
Thanks: 2
Thanked 0 Times in 0 Posts
Hi arjunprathap,

First do ssh keypairing.Copy your public key and paste it in the authorized keys in the remote server.Then post the error after excuting the script.
Sponsored Links
    #5  
Old 09-11-2012
arjunprathap arjunprathap is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 11 February 2013, 11:02 AM EST
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
Hi Priyak,

I have created the created the authorized key and ran the script.


Code:
asappl11dev.fmrco.com:/home/a501007% main.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
bash: line 17: syntax error near unexpected token `done'
'ash: line 17: `done < $qainpwarlist
asappl11dev.fmrco.com:/home/a501007%


Last edited by Franklin52; 09-11-2012 at 07:01 AM.. Reason: Please use code tags for data and code samples
Sponsored Links
    #6  
Old 09-17-2012
arjunprathap arjunprathap is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 11 February 2013, 11:02 AM EST
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
I got it fixed. the issue was due to the file type being dos. i converted it to unix and ran the script it worked fine. Thank everyone for your time to reply to my post.
The Following User Says Thank You to arjunprathap For This Useful Post:
Corona688 (09-17-2012)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running local script remotely with arguments in ksh lalitpct Shell Programming and Scripting 2 06-06-2012 05:03 AM
[Solved] Looking for script running before I run script again brianjb Shell Programming and Scripting 8 04-27-2012 09:32 AM
Sudo to execute script without passwd[solved] duckeggs01 Red Hat 0 03-19-2012 07:26 AM
[Solved] Help with running ps -e | less on nano script editor SANA4SPA Shell Programming and Scripting 2 10-22-2011 07:38 PM
sudo command remotely pvamsikr Shell Programming and Scripting 2 07-01-2008 01:45 AM



All times are GMT -4. The time now is 11:11 AM.