Remote reboot script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remote reboot script
# 1  
Old 08-26-2014
Remote reboot script

I'm a beginner in shell scripting and doing simple scripts for work requirement.

Code:
#!/bin/bash

for blade in  `cat machines.txt` 

do

  rsh  $blade 'reboot'

done

but when I try it with root password it's throwing error saying permission denied.We're using same root password for all the machines.
Does this work or is there any other way to reboot machines remotely using script?

RA

Last edited by Franklin52; 08-26-2014 at 07:24 AM.. Reason: Please use code tags
# 2  
Old 08-26-2014
Can you log in interactively with rsh?
# 3  
Old 08-26-2014
Lightbulb

How do you run/execute this script? I guess you try to run it like so: ./yourscript.sh but probably this won't work due to the missing execute bit on the newly created script.

I see two solutions: You set that bit manually with chmod u+x yourscript.sh or you override it like so bash yourscript.sh

Code:
$ cat <<EOF >test-script.sh
> #!/bin/bash
> echo TEST
> EOF
$ ./test-script.sh
bash: ./test-script.sh: Permission denied
$ bash test-script.sh 
TEST
$ chmod u+x test-script.sh 
$ ./test-script.sh 
TEST
$

# 4  
Old 08-27-2014
I agree with RudiC,

Can you prove that you can connect as a plain command first? If not, then there is a bigger problem than just a permission denied.

You could also try rsh localhost to check it's not the rsh command itself that is not denied.

A few questions though:-
  • What OS and versions are in play here?
  • Does it fail to connect to every server in the list, or just the first and abort?
  • Are you expecting to supply a password, or should this be a trusted connection?
  • When the shutdown/boot does fire off, how do you expect your process to return? Would being killed off by the shutdown be acceptable?

It might be slightly neater to use:-
Code:
while read blade
do
   rsh $blade 'reboot'
done < machines.txt



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

3. Shell Programming and Scripting

Start Script on system reboot

Hi, I have the following script that looks for a certain file and then executes the start.sh file. How can i make this process to kick when the box reboots. Please advice if ; then /u01/Essbase/Oracle//Middleware/user_projects/epmsystem7/bin/start.sh; rm... (8 Replies)
Discussion started by: thinkingeye
8 Replies

4. Shell Programming and Scripting

Need Remote server Reboot timings

Hi I need to know the reboot timings of remote servers (all unix/AIX server )with the help of shell script as the list of servers is 400+. None of the commands uses system name as parameter .What to do ? I am trying man -b in variety of codes am preparing but all in vain . #!/bin/ksh... (5 Replies)
Discussion started by: vinil
5 Replies

5. Shell Programming and Scripting

Triggering remote UNIX shell script from Remote desktop

I m trying to run a batch script in remote desktop which executes unix commands on the unix server...the problem is i wnt the output in HTML format.so in my batch script i m giving the cmd like ssh hostname path ksh HC_Report.ksh>out.html ...but it generates the HTML file in remote desktop .i... (2 Replies)
Discussion started by: navsan
2 Replies

6. Shell Programming and Scripting

Reboot script issue

Hi guys I am troubleshooting a script that informs me when a system has rebooted. The script is placed in /etc/rc3.d folder under root. The script is as follows: . /opt/scripts/function.sh PATH=/usr/bin EMAIL_ADD=<email address> ... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies

7. Shell Programming and Scripting

script to reboot multiple hosts

Hi Expert, How to create a script to reboot multiple hosts in linux? Thank you. (5 Replies)
Discussion started by: regmaster
5 Replies

8. Shell Programming and Scripting

Script to Reboot and Confirm

On my Solaris box I have to reboot some devices like below. However I think this can be done through a script. I've create a list that contains the devices IP addresses. Here's the logic: Reboot 4 devices and sleep for 5mins(300s.) While the devices are rebooting, I would like to confirm... (9 Replies)
Discussion started by: ravzter
9 Replies

9. Linux

Run a script during reboot/startup

Hi all, i have a script in /etc/init.d directory. -rwxr-xr-x 1 root root 26 Mar 28 16:00 myscript I need it to run when my linux reboots/startup. However is it not being executed. Do i need to put in in the rc.local directory? (1 Reply)
Discussion started by: new2ss
1 Replies

10. Solaris

different between soft reboot and hard reboot

Hi Guru's Can any want here could explain to me the different between soft reboot and hard reboot . Best Regards Seelan (3 Replies)
Discussion started by: seelan3
3 Replies
Login or Register to Ask a Question