Wednesday, April 24, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 624  / 2 Years ago, mon, december 6, 2021, 12:18:20

the script:



waktu=$(date +"%H")
kelompok="E20"
dir_skrg=$(pwd)

if (( $waktu >= 5 && $waktu <= 10 ))
then
salam="pagi"
elif (( $waktu >= 10 && $waktu <= 3 ))
then
salam="siang"
elif (( $waktu >= 4 && $waktu <= 7 ))
then
salam="sore"
else
salam="malam"
fi

echo “Selamat $salam $kelompok dengan user $USER, sekarang pukul $waktu dan pada direktori $dir_skrg”


it gives error:



script1.sh: 5: script1.sh: 14: not found
script1.sh: 8: script1.sh: 14: not found
script1.sh: 11: script1.sh: 14: not found


but not in my friend ubuntu's. andybody knows why?



14 is the hour when I run the script, I assume for some reason it thinks 14 is a file


More From » bash

 Answers
1

Looks like that is being run as a shell (sh) script rather than bash script. Try to run it like this:



bash script.sh


or enter the following as the first line of your script



#!/bin/bash


Then run as ./script.sh


[#35430] Tuesday, December 7, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tisglitter

Total Points: 307
Total Questions: 103
Total Answers: 119

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
tisglitter questions
Sun, Jan 9, 22, 16:18, 2 Years ago
Wed, Jun 1, 22, 18:03, 2 Years ago
Fri, Dec 10, 21, 14:31, 2 Years ago
;