X
X
ximik6662022-03-30 15:37:27
Python
ximik666, 2022-03-30 15:37:27

Bash script execution error, what could be the error?

I create my own action rule in fail2ban
actionban = /home/ban.sh ban <ip>

The ban.sh file itself

#!/bin/bash
/usr/bin/python3 /home/ban.py $1 $2


If you just run the ban.sh ban ip-addr file, then everything works fine.
If this rule is executed in action opnsense, then it gives an error
exec: /home/ban.sh ban <ip>
stderr: '/bin/sh: 1: Syntax error: end of file unexpected'
returned 2

The rights are exposed, it is simple ban.sh is started without any errors. What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2022-03-30
@Viji

and if
1) remove the line #! /bin/bash in general or replace with #!/bin/sh ?
2) replace the ban.sh script with ban.py - write it in python at the top of the line: #! /usr/bin/python3

A
Alexander Karabanov, 2022-03-30
@karabanov

Why run a python script from a bash script?
Run the python script right away.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question