0

bash

#!/bin/bash
echo "Please enter your name."
read name
then
echo "Good day $name, here is your calendar for this month:"
cal
echo "Today is" `date +%A`
if test $date -lt friday
then 
echo "TGIF"
fi
1

The permission needed is the execute permission. But you have some errors in your script, try to run it and it would show you the first error clearly

$ chmod u+x jason.sh 
$ ./jason.sh 
Please enter your name.
Jason
./jason.sh: line 4: syntax error near unexpected token `then'
./jason.sh: line 4: `then'

Fix it and run it again and you would get

$ ./jason.sh 
Please enter your name.
Jason
Good day Jason, here is your calendar for this month:
    February 2020   
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29

Today is Friday
./jason.sh: line 7: test: -lt: unary operator expected

You cannot compare dates like this, check How to compare two dates in a shell?

| improve this answer | |
0

We required to execute permission for a script if we are not running as root in the foreground.

chmod +x scriptName.sh

And there are few syntax errors in the script, you can use the below one.

#!/bin/bash
echo "Please enter your name."
read name
echo "Good day $name, here is your calendar for this month:"
cal
echo "Today is" `date +%A`
if [ "`date +%A`" == Friday ]
then
echo "TGIF"
fi
| improve this answer | |
0

To execute your script you need executable and read permission. At the end this is interpretative language and kernel need to read it (line by line). The command to give those permissions is:"

chmod u+rx script.sh

Of course you can run it with only read permission as parameter to the shell interpreter:

bash script.sh
| improve this answer | |
0

Hello @Jason you can try this

chmod u=rx,g=x,o=rwx jason.sh
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.