Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    shell script- syntax error: unexpected end of file

    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:

    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




  2. #2
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Ok, I solved the problem after all. It needed "elif" and 2 "fi" at the end.

 

 

Similar Threads

  1. Invalid File error when trying to upload profile pic
    By Miki47 in forum Forum Assistance
    Replies: 0
    Last Post: 11-18-2012, 09:49 AM
  2. Shell script to mount SAN
    By linux_new_bie in forum General Linux
    Replies: 0
    Last Post: 09-25-2012, 11:42 PM
  3. Error syntax 21 openldap
    By man12 in forum General Server
    Replies: 0
    Last Post: 09-14-2012, 05:22 AM
  4. Replies: 0
    Last Post: 01-10-2012, 09:51 AM
  5. File System Error
    By thelowbudget in forum General Linux
    Replies: 1
    Last Post: 01-08-2012, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
           








Check out Linux Central for Linux software and other goodies!





» Stats

Members: 3,580
Threads: 3,920
Posts: 9,446
Top Poster: Fred (1,486)
Welcome to our newest member, SLW210

» Links



Powered by vBadvanced CMPS