ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Find the character break - sh script

    IT Discussion
    osx apple shell shell scripting error
    4
    28
    2.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403
      last edited by DustinB3403

      OKAY, so here is my script, sanitized for the few secure things. Find what is breaking it as whenever I now run this on an Apple OSX device I get unexpected end of file. And I'm starting to lose it.

      #!/bin/sh
      
      if test ! $(which brew); then
       echo "Installing Brew"
        ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
      fi
      
      brew update
      
      brew install coreutils
      brew install gnu-sed --with-default-names
      brew install gnu-tar --with-default-names
      brew install gnu-indent --with-default-names
      
      brew install dockutil
      brew install mas
      brew install curl
      brew install macosvpn
      
      brew cask install adobe-acrobat-pro
      brew cask install adobe-acrobat-reader
      brew cask install adobe-creative-cloud
      brew cask install airtame
      brew cask install diskmaker-x
      brew cask install dropbox
      #brew cask install filezilla
      brew cask install firefox
      brew cask install fontexplorer-x-pro
      brew cask install google-chrome
      brew cask install i1profiler
      brew cask install microsoft-office
      brew cask install skype-for-business
      #brew cask install spotify
      brew cask install veracrypt
      brew cask install vlc
      brew cask install basecamp
      
      mas install 1295203466
      
      open /usr/local/Caskroom/adobe-creative-cloud/latest/Creative Cloud Installer.app/
      
      dockutil --remove Siri
      dockutil --remove Mail
      dockutil --remove Contacts
      dockutil --remove Calendar
      dockutil --remove Pages
      dockutil --remove Numbers
      dockutil --remove Messages
      dockutil --remove Safari
      
      dockutil --add "/Applications/Google Chrome.app"/
      dockutil --add "/Applications/Spotify.app"/
      dockutil --add "/Applications/Basecamp 3.app"/
      dockutil --add "/Applications/Firefox.app"/
      dockutil --add "/Applications/Veracrypt.app"/
      dockutil --add "/Applications/FontExplorer X Pro.app"/
      dockutil --add "/Applications/Microsoft Excel.app"/
      dockutil --add "/Applications/Microsoft Word.app"/
      dockutil --add "/Applications/Microsoft Powerpoint.app"/
      dockutil --add "/Applications/Microsoft Outlook.app"/
      
      sudo systemsetup -setremotelogin on
      
      dseditgroup com.apple.access_ssh
      dseditgroup -o create -q com.apple.access_ssh
      
      sudo dseditgroup -o edit -a admin -t group com.apple.access_ssh
      
      sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users admin,admin -privs -DeleteFiles -ControlObserve -TextMessages -OpenQuitApps -GenerateReports -RestartShutDown -SendFiles -ChangeSettings -specifiedUsers
      
      sudo macosvpn create --l2tp "VPN Name" --endpoint "vpn.domain.com" --username '' --password '' --shared-secret password
      
      softwareupdate -i -a
      
      1 Reply Last reply Reply Quote 0
      • black3dynamiteB
        black3dynamite
        last edited by

        What was the last thing you add or changed?

        DustinB3403D 1 Reply Last reply Reply Quote 0
        • DustinB3403D
          DustinB3403 @black3dynamite
          last edited by

          @black3dynamite At this point I don't recall.

          1 Reply Last reply Reply Quote 0
          • DustinB3403D
            DustinB3403
            last edited by

            The complaint is with the final line in the script, which simply searches for OSX updates, and installs them.

            1 1 Reply Last reply Reply Quote 0
            • DustinB3403D
              DustinB3403
              last edited by

              Paging @wirestyle22 since he commented on my last reply before this topic.

              1 Reply Last reply Reply Quote 0
              • 1
                1337 @DustinB3403
                last edited by

                @DustinB3403 said in Find the character break - sh script:

                The complaint is with the final line in the script, which simply searches for OSX updates, and installs them.

                Don't you need to be root?
                sudo softwareupdate -ia

                DustinB3403D 1 Reply Last reply Reply Quote 1
                • DustinB3403D
                  DustinB3403 @1337
                  last edited by

                  @Pete-S While yes, this doesn't appear to be the issue.

                  I posted this same thing to my GH, here it is from 5 days ago.

                  Direct link https://raw.githubusercontent.com/Jarli01/OSX-Configuration/master/brew-setup.sh

                  1 Reply Last reply Reply Quote 0
                  • DustinB3403D
                    DustinB3403
                    last edited by

                    So as is, the script bitches about the first blank line (2) with unexpected end of file and line (74) as well.

                    : command not foundew/new.sh: line 2
                    /Volumes/NO NAME/Brew/new.sh: line 74: syntax error: unexpected end of file

                    1 1 Reply Last reply Reply Quote 0
                    • DustinB3403D
                      DustinB3403
                      last edited by

                      Testing just the if statement works without issue.

                      1 Reply Last reply Reply Quote 0
                      • black3dynamiteB
                        black3dynamite
                        last edited by

                        This line with open /usr/local/Caskroom/adobe-creative-cloud/latest/Creative Cloud Installer.app/ needs a quotes.

                        open "/usr/local/Caskroom/adobe-creative-cloud/latest/Creative Cloud Installer.app/"

                        DustinB3403D 1 Reply Last reply Reply Quote 0
                        • DustinB3403D
                          DustinB3403 @black3dynamite
                          last edited by

                          @black3dynamite doesn't fix it on my end.

                          1 Reply Last reply Reply Quote 0
                          • 1
                            1337 @DustinB3403
                            last edited by

                            @DustinB3403 said in Find the character break - sh script:

                            So as is, the script bitches about the first blank line (2) with unexpected end of file and line (74) as well.

                            : command not foundew/new.sh: line 2
                            /Volumes/NO NAME/Brew/new.sh: line 74: syntax error: unexpected end of file

                            Oh, that's an easy one. Can't have space in the directory name. Need " around it or change space to _.

                            DustinB3403D 1 Reply Last reply Reply Quote 0
                            • DustinB3403D
                              DustinB3403 @1337
                              last edited by

                              @pete-s except that isn't the issue, as I can run the individual command without any interference.

                              1 1 Reply Last reply Reply Quote 0
                              • 1
                                1337 @DustinB3403
                                last edited by 1337

                                @DustinB3403 said in Find the character break - sh script:

                                @pete-s except that isn't the issue, as I can run the individual command without any interference.

                                Your output seems garbled but the first error is "command not found". If you get it on the second line then the first line is where the error is. Command not found is usually a problem with the directory or the path.

                                Try enable debugging on the bash script. http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html
                                Makes it easier to see when and where the error/problem is.

                                PS.I'm talking about softwareupdate where you get the error. It's bash script right?

                                DustinB3403D 1 Reply Last reply Reply Quote 0
                                • DustinB3403D
                                  DustinB3403 @1337
                                  last edited by

                                  @Pete-S yeah, the software update command has worked on 7 other systems.

                                  1 Reply Last reply Reply Quote 0
                                  • M
                                    marcinozga
                                    last edited by

                                    Remove / at the end of dockutil lines. Is there any chance this script was written on Windows machine? Perhaps EOL needs converting from Windows CR LF to unix LF.

                                    What happens if you change shebang to /bin/bash?

                                    DustinB3403D 1 Reply Last reply Reply Quote 1
                                    • DustinB3403D
                                      DustinB3403 @marcinozga
                                      last edited by

                                      @marcinozga I was actually considering just rewritting the entire thing on a Apple computer for good measure.

                                      I'll remove the / at the ends of the lines, but those were from autocomplete in apple terminal.

                                      M 1 Reply Last reply Reply Quote 0
                                      • M
                                        marcinozga @DustinB3403
                                        last edited by

                                        @DustinB3403 I'd try eliminating the problem line by line, or at least by sections. You also have admin user listed twice in kickstart line, fix that too.

                                        DustinB3403D 1 Reply Last reply Reply Quote 0
                                        • DustinB3403D
                                          DustinB3403 @marcinozga
                                          last edited by

                                          @marcinozga that is to apply the user account that I want to have local admin rights 🙂

                                          M 1 Reply Last reply Reply Quote 0
                                          • M
                                            marcinozga @DustinB3403
                                            last edited by

                                            @DustinB3403 but why do you have admin there twice? It's a list of users, separated by comma, what you're doing is setting privileges for admin user, and then for admin user again. It doesn't make much sense.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • First post
                                              Last post