S
stratosam
Guest
Hello, I am new to linux. I am currently trying Ubuntu and I was trying to write a shell script to perform automatic shutdown/reboot after some time (selected by the user). But it gives me the "syntax error: unexpected end of file" message. Here is the script:
In my earlier versions I tried to perform single operations, for example to get it to shutdown in 5 minutes. Until I added the "if" for the selection between shutdown and reboot I had no problems. I look it over and over for mistakes, but I can't see any. I don't know what it is. Can you help me please? Thank you in advance
Code:
#!/bin/bash
echo "This script shuts down/reboots the computer"
echo "Please select the prefered operation:
1.Shutdown
2.Reboot"
read selection
if (( ("$selection" == "1") ));then
echo "Give the amount of minutes you want the computer to stay on before shutdown"
read minutes
sudo shutdown -h +"$minutes"
else if (( ("$selection" == "2") ));then
echo "Give the amount of minutes you want the computer to stay on before it reboots"
read minutes
su shutdown -r +"$minutes"
fi
In my earlier versions I tried to perform single operations, for example to get it to shutdown in 5 minutes. Until I added the "if" for the selection between shutdown and reboot I had no problems. I look it over and over for mistakes, but I can't see any. I don't know what it is. Can you help me please? Thank you in advance