Executing remotely the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing remotely the script
# 1  
Old 02-20-2007
Executing remotely the script

Hi All,

I have a script to be executed in another machine. I connect to that machine from another server as a root ( this is the only configured access, as i cannot log in as a normal user). After that I have to switch to a normal user and that I can be able to executge that script. But all this is done manually, that why Im interested in finding a way to automate the execution and not typing always:

remsh machine_name
su - sc
./script.sh

Please could anyone help me
# 2  
Old 02-20-2007
Quote:
Originally Posted by elthox
Hi All,

I have a script to be executed in another machine. I connect to that machine from another server as a root ( this is the only configured access, as i cannot log in as a normal user). After that I have to switch to a normal user and that I can be able to executge that script. But all this is done manually, that why Im interested in finding a way to automate the execution and not typing always:

remsh machine_name
su - sc
./script.sh

Please could anyone help me
Code:
remsh machine_name "su - sc -c \"./script.sh\""

# 3  
Old 02-20-2007
Thanks for your reply
I tried what you wrote but it didnt succeed. Here is the output

vasstat1:/tmp/vms1# remsh smsc1 "su - sc -c \"./kot\""
ttytype: couldn't open /dev/tty for reading
You have mail.
stty: : Unknown error
Not a terminal
stty: : Unknown error
stty: : Unknown error
su: ./kot: not found.
# 4  
Old 02-20-2007
Quote:
Originally Posted by elthox
Thanks for your reply
I tried what you wrote but it didnt succeed. Here is the output

vasstat1:/tmp/vms1# remsh smsc1 "su - sc -c \"./kot\""
ttytype: couldn't open /dev/tty for reading
You have mail.
stty: : Unknown error
Not a terminal
stty: : Unknown error
stty: : Unknown error
su: ./kot: not found.
Does the script "kot" run as a cron job or does it request input?

The last error can be solved easy:
su: ./kot: not found.

remsh smsc1 "su - sc -c \"<full path to location of kot>/kot\""
# 5  
Old 02-20-2007
It is OK now, I run it successfully. Just one more question. How can I transmitt one or two parameter with the script

E.g remsh smsc1 "su - sc -c \"./kot.sh 2007-01 06845444\""

Is it correct like this?
# 6  
Old 02-20-2007
Quote:
Originally Posted by elthox
It is OK now, I run it successfully. Just one more question. How can I transmitt one or two parameter with the script

E.g remsh smsc1 "su - sc -c \"./kot.sh 2007-01 06845444\""

Is it correct like this?
Looks fine to me
# 7  
Old 02-21-2007
Hi again,

The output of the script above is supposed to be returned to the calling place.
I use rcp like below

rcp -p /var/opt/nokia/smsc/logdata/billfiles/out 172.20.1.25:/opt/output/daily_stats/config

I cannot understand why sometimes works and sometimes no, like today. It gives me this error
remshd: Login incorrect

Any clue?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run yes/no script remotely

I have this script in server2 # cat /root/yesno.sh #!/bin/bash read -p "are you sure?" -n 1 -r if $ ]]; then echo "" echo "YES" else echo "NO" fi # sh /root/yesno.sh are you sure?y YES (5 Replies)
Discussion started by: anil510
5 Replies

2. Shell Programming and Scripting

[perl] execute remotely script

Hello Can some help with write part of perl script I need something like this in perl SSH="/bin/ssh -o BatchMode=yes -o" USER="test" SRV="server" SCRIPT_TO_EXEC="/tmp/test.sh" -> shell script OUT=/tmp/out.file ${SSH} -l ${USER} ${SRV} 'sudo /usr/bin/ksh -s' < ${SCRIPT_TO_EXEC} >> ${OUT}... (1 Reply)
Discussion started by: vikus
1 Replies

3. Shell Programming and Scripting

Remotely Executing Shell Script - Problems

Hey Lads, I have a shell script on a remote Server X that i need to execute from Server A. the script executes fine locally but remotely does not. It appears the script on the remote machine is calling another shell script which only has an array defined . Please see below the errors. ... (10 Replies)
Discussion started by: Irishboy24
10 Replies

4. Shell Programming and Scripting

Then error while running script remotely

facing issue with then error while running a local script aginst a remote server. i facing the same issue in multiple scripts. So what i am missing here or what is needed. #!/bin/ksh echo "enter the filename" read file if then echo "file exists" else echo "file does not exists" fi ... (0 Replies)
Discussion started by: NarayanaPrakash
0 Replies

5. Shell Programming and Scripting

Problems with remotely executing scripts

Hi, in the below command, i export a value to a variable which later is used by the script, however i dont see the exported value is actually been exported. ssh user@host "export var=/path/ ; cd /path/ ; ./script" how can i use the above command with proper value of var remotley (7 Replies)
Discussion started by: suraj.sheikh
7 Replies

6. Shell Programming and Scripting

Remotely Execute a script

Hi, What is the best way to remotely execute a script? Scenario: 1 Unix box creates a file and moves it to a 2nd unix box 2nd unix box must then move the file to a windows server How can i execute the ftp script on the 2nd server, I need to schedule the command to automate it!? I... (3 Replies)
Discussion started by: mcclunyboy
3 Replies

7. UNIX for Advanced & Expert Users

script to remotely start an application instance

just wanted to ask if anybody have script template for the subject above so I can make ti as my guide? example a. server 1.1.1.1: restart script located at /etc/init.d/glassfish.sh b. server 2.2.2.2: central script that support admin will use to execute to restart the /etc/init.d/glassfish.sh... (0 Replies)
Discussion started by: lhareigh890
0 Replies

8. Shell Programming and Scripting

remotely call function from local script

The following code doesn't work properly which means it doesn't displays remote output. #!/bin/ksh #################### Function macAddressFinder ######################## macAddressFinder() { `ifconfig -a > ipInterfaces` `cat ipInterfaces` }... (2 Replies)
Discussion started by: presul
2 Replies

9. IP Networking

Script for Changing an IP address remotely

Hi Fellows, I am a beginner in shell scripting struggling with a script. I have to write a script to change the IP address of computer remotely running on solaris or Linux ,which is to be added to a cluster.I am working on unix. Presently the administrator runs a sanity check script on the... (3 Replies)
Discussion started by: pranav.mehta3
3 Replies

10. Shell Programming and Scripting

Remotely executing awk command

ssh user@machine awk '{ split ($1,ar,"!");print ar}' samp >samp1 Error: Unmatched '. However on <machine> awk '{ split ($1,ar,"!");print ar}' samp >samp1 executes successfully. Any suggestions. (1 Reply)
Discussion started by: bishweshwar
1 Replies
Login or Register to Ask a Question