You are not logged in.
Pages: 1
Hi guys, Im trying to use this bash script I found online but Im getting a syntax error when I try to run it. I have no experience with bash, can anyone see what the problem is?
##### waktu_solat start #########ipraytime -lat 3.10 -lon 101.42 -u +8.00 -a 1 | awk 'NR==11 {print "\nFajr\t\t"$2″\nShuruq\t\t"$3″\n" "Zuhr\t\t"$4″\nAsr\t\t"$5″\nMaghrib\t\t"$6″\nIsha\t\t"$7}'
# Kelate – (KB – pantai sabak) – Home sweet home
#echo "Prayer Time (KB)"
#ipraytime -lat 6.10 -lon 102.19 -u +8.00 -a 1 | awk 'NR==11 {print "Subuh\t\t"$2″\nShuruq\t\t"$3″\n" "Zuhur\t\t"$4″\nAsar\t\t"$5″\nMaghrib\t"$6″\nIsya\t\t"$7}'
#KL (bangi – abu bakar baginda) – Umah sewa
echo "Prayer Time (KL)"
ipraytime -lat 2.57 -lon 101.44 -u +8.00 -a 1 | awk 'NR==11 {print "Subuh\t\t"$2″\nShuruq\t\t"$3″\n" "Zuhur\t\t"$4″\nAsar\t\t"$5″\nMaghrib\t"$6″\nIsya\t\t"$7}'
# KK (Kota Kinabalu, Graceville)
#echo "Prayer Time (KK)"
#ipraytime -lat 5.57 -lon 116.03 -u +8.00 -a 1 | awk 'NR==11 {print "Subuh\t\t"$2″\nShuruq\t\t"$3″\n" "Zuhur\t\t"$4″\nAsar\t\t"$5″\nMaghrib\t"$6″\nIsya\t\t"$7}'
#### waktu_solat end ###
This is the error Im getting:
./prayer.sh: line 8: syntax error near unexpected token `('
./prayer.sh: line 8: `echo "Prayer Time (KL)"'
Last edited by wankel (2009-08-02 23:26:19)
Offline
The double quotes are "stylized." Replace them with real double-quote characters and line 8 works fine.
[marc@~] echo "Prayer Time (KL)"
-bash: syntax error near unexpected token `('
[marc@~] echo "Prayer Time (KL)"
Prayer Time (KL)
Offline
The double quotes are "stylized." Replace them with real double-quote characters and line 8 works fine.
[marc@~] echo "Prayer Time (KL)" -bash: syntax error near unexpected token `(' [marc@~] echo "Prayer Time (KL)" Prayer Time (KL)
Thanks peart, that solved that problem. However Im getting an error on the next line and Im not sure how to get around this one either:
./prayer.sh
Prayer Time (KL)
awk: 'NR==11
awk: ^ invalid char 'â' in expression
Last edited by wankel (2009-08-02 23:14:53)
Offline
Those lines should like:
echo "Prayer Time (KL)"
ipraytime -lat 2.57 -lon 101.44 -u +8.00 -a 1 | awk 'NR==11 {print "Subuh\t\t"$2"\nShuruq\t\t"$3"\n" "Zuhur\t\t"$4"\nAsar\t\t"$5"\nMaghrib\t"$6"\nIsya\t\t"$7}'
"I'm Winston Wolfe. I solve problems."
~ Need moar games? [arch-games] ~ [aurcheck] AUR haz updates? ~
Offline
Those lines should like:
echo "Prayer Time (KL)" ipraytime -lat 2.57 -lon 101.44 -u +8.00 -a 1 | awk 'NR==11 {print "Subuh\t\t"$2"\nShuruq\t\t"$3"\n" "Zuhur\t\t"$4"\nAsar\t\t"$5"\nMaghrib\t"$6"\nIsya\t\t"$7}'
Thanks arkham and peart, all is working well now
Offline
Hi,
I'm trying to use the same script. When I copy and paste the above code it doesn't show me the times but just shows the titles Subuh, Shurug etc.
Any ideas?
Thanks.
Offline
Figured out the problem.
In the above code it must be 'NR=12'.
Cheers.
Offline
Pages: 1