Why am I getting this error.... [: =: unary operator expected error
Thanks in advance.
giving me an error on the bolded lines
Code:
#!/bin/sh
# iOS-Ad-Remover
# Marshall Ford @ marshallbford@gmail.com
# This project is hosted @ http://ios-ad-
# remover.sourceforge.net
# Under the GNU GPL open source license
clear
echo
if [ `id -u` != 0 ]; then echo "You need to be root to run this script."; exit 0; # required by reboot command
echo
fi
set -xv
if [ -f "/var/mobile/iOS_Ad_Remover-`date +%d%m%y`.log" ]; then
rm iOS_Ad_Remover-`date +%d%m%y`.log
fi
logname=iOS_Ad_Remover-`date +%d%m%y`.log
echo "iOS-Ad-Remover Log File" >> $logname
datetime=`date +%c_%p`
echo "$datetime" >> $logname
deviceinfo="Device: "`deviceinfo -p`
echo "$deviceinfo" >> $logname
if [ -f "/var/lib/dpkg/info/com.ericasadun.utilities.list" ]; then # Erica Utilities check
:
else
echo "Erica Utilities not installed" >> $logname
echo "Error: You need to install Erica Utilities from Cydia"
sleep 5
exit
fi
if [ -d "/Applications/iFile.app" ]; then # iFile check
:
else
echo "Error: iFile not installed" >> $logname
echo "You need to install iFile from Cydia"
sleep 5
exit
fi
echo "Erica Utilities and iFile installed" >> $logname
if [ -f "/var/mobile/adremover.sh" ]; then
:
else
echo "This script is not called adremover.sh or is not located at /var/mobile/adremover.sh"
echo "Error: Script name or location not correct" >> $logname
fi
date # Start intro
echo
echo "Welcome to iOS-Ad-Remover Beta 1.0
"
sleep 3
echo "This script is similar to Adblock in that it will remove ads from most apps, some websites, and in Cydia.
"
sleep 5
echo "Click RETURN when you want to continue
"
read
echo "You will need to meet the following requirements...
"
read
echo "1. iFile and Erica Utilities installed and updated
"
read
echo "2. This script must be located @ /var/mobile
"
read
echo "3. This script will perform a reboot, you must have an untethered jailbreak or have access to a computer to power back on.
"
sleep 3
echo # end intro
echo "Have you completed the requirements and still want to continue?
"
echo "y/n?
"
read answer
if [ $answer = "y" ]; then
clear
# download host file
echo "Do you have the latest host file downloaded and located in /var/mobile/Media/Downloads?
"
echo "y/n?
"
read hosta
if [ $hosta = "y" ]; then
:
if [ -f "/var/mobile/Media/Downloads/fhosts" ]; then
:
else
echo "The host file does not exist"
echo "Error: The host file did not exist" >> $logname
sleep 3
openURL http://sourceforge.net/projects/ios-ad-remover/files/iOS-Ad-Remover/
exit
fi
fi
if [ $hosta = "n" ]; then
echo "User sent to download host file" >> $logname
openURL http://sourceforge.net/projects/ios-ad-remover/files/iOS-Ad-Remover/
exit
fi
echo # backup process
sleep 1
echo
echo "Backing-up"
sleep 3
cd ..
cd ..
cd var/mobile/Media/Downloads
if [ -d "/var/mobile/Media/Downloads/Backup" ]; then
:
else
mkdir Backup
fi
cd ..
cd ..
cd ..
cd ..
cd etc
cp fhosts /var/mobile/Media/Downloads/Backup
cd /var/mobile/Media/Downloads/Backup
cp fhosts $datetime-backup-fhosts # rename process
rm fhosts # rename process
echo
echo "Done"
echo
echo "Old host file backed-up" >> $logname # backup done
sleep 1
echo "Changing the host file..."
sleep 3
cd ..
cd ..
cd ..
cd ..
cd ..
cd etc
rm fhosts
cd ..
cd /var/mobile/Media/Downloads
cp fhosts /etc
cd ..
cd /var/mobile/Media/Downloads
rm fhosts
echo
echo "You have successfully removed the majority of ads on iOS.
"
echo "You have successfully removed the majority of ads on iOS" >> $logname
sleep 3
echo "If you find an app that does not function"
echo "because of the ad-removal please contact me at marshallbford@gmail.com"
read
echo "Reboot performed" >> $logname
reboot # needed to insure host file install
fi
if [ $answer = "n" ]; then
clear
echo "iOS-Ad-Remover was stopped by the user" >> $logname
echo "iOS-Ad-Remover was stopped by the user."
sleep 3
echo
echo "Good Bye"
sleep 3
fi
Hi
I am doing a script like
if
then
echo "table name dosent exist"
exit
fi
the problem is if $table_name is null then i am getting the error
Please help me
Thanks in advance (2 Replies)
hi
i am trying to compare a value with value 50. but i am getting
"
I am using
if
then
echo "------------"
fi
please help
thanks in advance
Satya (2 Replies)
Im trying to fix my /etc/weekly that rotates various logs however it does them no matter what filesize they are and i want them to only do it if there file size exceeds 2M or something. So I'm playing with a script to get the filesize using a ls -l command which works and puts the value into a... (3 Replies)
find . -name "*.*"|xargs grep WT:DBF_WL>> $F
Wfexist=`cat $F|grep $i`
echo $Wfexist
if ;
then
echo $Wfexist
echo "Workflow Exist"
else
touch $O
chmod 777 $O
echo $Wfexist
echo $WfExist >> $O
fi
I am getting the error that -ne: unary operator expected in the line with red... (2 Replies)
i=0
while
Shell script reports an error "unary operator expected" pointing the above line.
$i by default is 0 and holds integer value and $buf is also holding integer value.
Please can some one let me know what is missing.
Thanks. (1 Reply)
Hiya all,
Why do I get a :unary operator expected when I try to put a condition statement in my shell script (sh) like so and how to fix?
if ; then
echo "say hello"
else
echo "don't say hello"
fi
? It seems if the script receives an argument it works but if I don't put an... (4 Replies)
Hi
I have problem with my script.
I dont now why but i don't change anything and script stop working.
this is my code:
#!/bin/sh
for i in `ps -A | grep pocron.sh | grep -v grep | awk '{print $2}'`
do
COUNT=$((COUNT+1))
done
ostatnie_wykonanie=`cat porader.log`... (1 Reply)
Hi All,
I'm assigning a numeric value to variable count=2, well its being assigned by code above the if condition.
I want to test for 2 conditions , when $count = 0 or $count <=2 and do something when the condition matches. here is my code, but i run into the infamous :
if ]
then
... (2 Replies)
In all my Googling, this usually happens when someone is comparing a variable, and that variable is unset. That doesn't appear to be the case for me...
#!/bin/bash -x
while read line
do
f=$(echo $line | tr -s ' ' | cut -d' ' -f 3)
echo $f
if
then
echo "This... (2 Replies)