P
P
Pavel2018-12-19 23:01:37
bash
Pavel, 2018-12-19 23:01:37

Why does bash swear line 39: syntax error: unexpected end of file?

#!/bin/bash
ocpath='/var/www/nextcloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'

printf "Creating possible missing Directories\n" 
mkdir -p $ocpath/data 
mkdir -p $ocpath/assets 
mkdir -p $ocpath/updater 

printf "chmod Files and Directories\n" 
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640 
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750 

printf "chown Directories\n" 
chown -R ${rootuser}:${htgroup} ${ocpath}/ 
chown -R ${htuser}:${htgroup} ${ocpath}/apps/ 
chown -R ${htuser}:${htgroup} ${ocpath}/assets/ 
chown -R ${htuser}:${htgroup} ${ocpath}/config/ 
chown -R ${htuser}:${htgroup} ${ocpath}/data/ 
chown -R ${htuser}:${htgroup} ${ocpath}/themes/ 
chown -R ${htuser}:${htgroup} ${ocpath}/updater/ 

chmod +x ${ocpath}/occ 

printf "chmod/chown .htaccess\n" 

if [ -f ${ocpath}/.htaccess ] 
  then 
    chmod 0644 ${ocpath}/.htaccess 
    chown ${rootuser}:${htgroup} ${ocpath}/.htaccess 
  fi 
if [ -f ${ocpath}/data/.htaccess ] 
  then 
    chmod 0644 ${ocpath}/data/.htaccess 
    chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess 
fi

actually, I’m generally 0 in the bash, I don’t even know what it’s eaten with, I just need to execute the file, and it swears bastard)) , google says the error most often happens because it’s not closed if with the fi tag, but I don’t seem to have that case, how to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2018-12-19
@mrusklon

During the copy-paste campaign, an unprintable character came across (this is perfectly visible in the hex editor).
just delete the last line completely and type fi with pens.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question