Line 54: warning: here is the document on line 42 delimited by the destination file (requires "EOF")
I got a bash script, but when I ran it I got some error:
line 54: warning: here is the document on line 42 delimited by the destination file (requires `EOF ')
#!/bin/bash
echo "PODAJ IMIE"
read imie
echo "PODAJ NAZWISKO"
read nazwisko
alias="$imie$nazwisko"
echo "$alias"
while [ 1 ]
do
i=1
if [ `egrep $alias /etc/passwd |wc -l` -gt 0 ]; then i=0
fi
if [ $i -eq 0 ]; then
echo "Uzytkownik o podanym aliasie już istnieje!"
echo "PODAJ INNY ALIAS np. "$alias"1"
read alias
else
echo "PODAJ HASLO"
read -s password
echo "PODAJ NUMER POKOJU"
read pokoj
#adduser --disabled-password --gecos "$imie $nazwisko,$pokoj, ," $alias
adduser --quiet --disabled-password -shell /bin/bash --home /home/$alias --gecos "$imie $nazwisko, $pokoj, , " $alias
echo "$alias:$password" | chpasswd
#echo -e "$haslo\n$haslo\n" | sudo passwd $alias
dir=/home/$alias
mkdir $dir/public_html
mkdir $dir/samba
cd $dir/public_html
mkdir private_html
cat <<EOF >>$dir/.bashrc
echo "alias ps =/bin/ps"
echo "alias ls =/bin/ls"
t=\`date +%F.%H:%M:%S\`
echo "WITAJ\n"
echo "DZISIAJ MAMY:\$t"
echo "TWOJE OSTATNIE LOGOWANIE:" && " lastlog -u \$USER | tail -n 1 | awk '{print \$4" "\$5" "\$6" "\$7" "\$9}'"
EOF
break
fi
done
source to share
You can also use
<Tab><Tab>cat <<-EOF >>$dir/.bashrc
#--------------------^- added a "-" char
<Tab><Tab> echo " ... "
<Tab><Tab> echo " ... "
<Tab><Tab>EOF
where EOF now precedes the character -
. This indicates to the shell that the closing token here of the file will (maybe) be indented with tabs . If you write, by chance, <Tab><Tab><Space>EOF
it won't match, but 0,1,2, ..., 100 <Tab>EOF
will .
IHTH
source to share
EOF
must be at the beginning of the line and without anything after (including spaces).
Some of the ones echo
in this block are suspicious. The text before the ending marker will be copied to the file as it is after the variable replacement, rather than executed - and it doesn't look like you want to replace here.
Try this: (note the quotes around "EOF"
in the line cat
)
cat <<"EOF" >>$dir/.bashrc
alias ps=/bin/ps
alias ls=/bin/ls
t=$(date +%F.%H:%M:%S)
echo "WITAJ\n"
echo "DZISIAJ MAMY: $t"
echo "TWOJE OSTATNIE LOGOWANIE:" $(lastlog -u $USER | tail -n 1 | awk '{print $4" "$5" "$6" "$7" "$9}')
EOF
source to share