Can't explain why this is happening. Here's the script:
#!/bin/bash
echo "Hello World"
Here's the terminal output:
$ python ./test.sh
File "./tellapart_mac_setup.sh", line 2
echo "Hello World"
^
SyntaxError: invalid syntax
$ echo "hello world"
hello world
$ which bash
/bin/bash
$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.
The message reads SyntaxError: invalid syntax , but that's not very helpful. The traceback points to the first place where Python could detect that something was wrong. To fix this sort of error, make sure that all of your Python keywords are spelled correctly.
$1 means an input argument and -z means non-defined or empty. You're testing whether an input argument to the script was defined when running the script. Follow this answer to receive notifications.
$? is the exit status of the most recently-executed command; by convention, 0 means success and anything else indicates failure. That line is testing whether the grep command succeeded. The grep manpage states: The exit status is 0 if selected lines are found, and 1 if not found.
$() – the command substitution. ${} – the parameter substitution/variable expansion.
Looks like you're parsing it with python, since it's not a python script - it of course will throw errors in python's compiler.
It's a bash script, so just use bash to process it:
./test.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With