LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   reboot script (https://www.linuxquestions.org/questions/linux-newbie-8/reboot-script-4175434110/)

SIcan 10-25-2012 07:36 PM

reboot script
 
how can i restart my pc with a script without password

cbtshare 10-25-2012 07:37 PM

the same way you would at the command line.Just put that in a script

SIcan 10-25-2012 07:50 PM

Thank you the quick answer !

i have tried :

reboot

It works in the command line but not in the script

shivaa 10-25-2012 11:33 PM

Which OS you're using? And what's need to doing this.
As far as I know, you can do such password less login after a reboot, in any remote system using command line. But since you're trying it on your local system, then it shouldn't accept your password through a script because it would prompt for a password on GUI based login prompt, not on command line.
Second problem is, script should be executed 2 times, one before rebooting to invoke reboot command, and second after reboot to enter username & password, so how would you run a script second time before login into the system? It's practically not seem possible.
On the other hand, there's little possibility by adding such script in /etc/init/rc.d directroy, and you can explore it.

SIcan 10-27-2012 11:33 PM

Thank you shivaa,

the os is linux ubuntu 12,

I have a PC (station) connected to internet that i want remote .
i get regulary information from and i send information and commands to it.sometime to resolve errors i have to reboot it.
that the reason why i look for a script that i can send it to reboot it.


i get

SIcan 10-28-2012 10:28 PM

i have tried with chown root:root and chmod 475
but it asks for password ???

shivaa 10-28-2012 11:28 PM

Is the PC you want to reboot a remote one? If yes, then how are you accessing it, I mean what tool and commands (i.e. ssh, telnet etc) you're using?
Anyway, as far as I could understand, you can create a script somethng like this (below is just a hint, not exact script):
Code:

#!/bin/bash
user=<your-username>
host=<remote_host>

ssh $user@<remote_host> "reboot" 2>/dev/null  ## Generate rsa/dsa keys to login into that remote machine without a password
sleep 2m
ping -c 2 <remote-host>
ssh $user@<remote_host>

So let's know first what you've tried so far.
Quote:

i have tried with chown root:root and chmod 475
What's link of chroot with reboot script? Please be clear.

VDP76 10-29-2012 12:36 PM

hi SIcan,
afaik, reboot command requires root privileges to be launched; but there is a way around it: adding exceptions to /etc/sudoers file, see here for details...

SIcan 10-29-2012 10:41 PM

Thank you VDP76 for the docs. I will try to the use them.
I know that what the script I look for, is a little special.
The Remote PC accept no incoming connection. it pools the commands from cloud and execute the corresponding script.

SIcan 11-03-2012 08:44 AM

Thanks for your help,
I have reslve it by passing the password in the script using expect


All times are GMT -5. The time now is 10:17 PM.