Unix is totally new to me and this error message I got is totally foreign to me. Can somebody PLEASE look at my code to see why I am getting this unary operator expecter error.
Thank you!!
#!/bin/sh
input = 0
clear
while [ $input != 6 ]
do
echo " Menu Choice"
echo " 1) List date, and users who are currently logging"
echo " 2) Print the current working directory"
echo " 3) List all files in the current working directory"
echo " 4) Check the first argument to the script is"
echo " a file with read permission"
echo " 5) Prompt the user for the name of a file"
echo " create a backup copy of the file by appending"
echo " the prcess ID to the filename entered"
echo " 6) Exit"
echo -n "Enter your choice"
read input
case "$input" in
1) clear
echo "Action 1 taken"
echo -n "The current date is"
date
echo "The current user on the system"
who
sleep 5
;;
2) clear
echo "Action 2 taken"
echo -n "The current working directory is:"
pwd
echo ""
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
3) clear
echo "Action 3 taken"
echo "The file"
ls -al
echo ""
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
4) clear
echo "Action 4 taken"
echo -n "Enter your file name: "
read filename
if [ -r $1 filename ]
then
more $1 filename
else
echo "Error $1 filename does not have the read permission"
fi
echo ""
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
5) clear
echo "Action 5 taken"
echo -n "Enter your file name: "
read filename
if cp $filename $filename.$$
then
echo "Your copied file is $filename.$$"
else
echo " **\n** Cannot copy the request file\n**"
fi
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
6) Exit
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
*) clear
echo "Please enter 1 to 6 only"
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
esac
done
Thank you!!
#!/bin/sh
input = 0
clear
while [ $input != 6 ]
do
echo " Menu Choice"
echo " 1) List date, and users who are currently logging"
echo " 2) Print the current working directory"
echo " 3) List all files in the current working directory"
echo " 4) Check the first argument to the script is"
echo " a file with read permission"
echo " 5) Prompt the user for the name of a file"
echo " create a backup copy of the file by appending"
echo " the prcess ID to the filename entered"
echo " 6) Exit"
echo -n "Enter your choice"
read input
case "$input" in
1) clear
echo "Action 1 taken"
echo -n "The current date is"
date
echo "The current user on the system"
who
sleep 5
;;
2) clear
echo "Action 2 taken"
echo -n "The current working directory is:"
pwd
echo ""
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
3) clear
echo "Action 3 taken"
echo "The file"
ls -al
echo ""
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
4) clear
echo "Action 4 taken"
echo -n "Enter your file name: "
read filename
if [ -r $1 filename ]
then
more $1 filename
else
echo "Error $1 filename does not have the read permission"
fi
echo ""
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
5) clear
echo "Action 5 taken"
echo -n "Enter your file name: "
read filename
if cp $filename $filename.$$
then
echo "Your copied file is $filename.$$"
else
echo " **\n** Cannot copy the request file\n**"
fi
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
6) Exit
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
*) clear
echo "Please enter 1 to 6 only"
echo "------------Hit enter key to continue-----"
read VAR
sleep 5
;;
esac
done