Python & Bash Code User Expire Scipts
Hi
Im new to Python coding. The below code and works when executing via our program. Code:
#**************************************# For some reason the below code returns with no data, im not sure if its written correct. Code:
#**************************************# Both these checks calls on the below main bash script: Code:
user@server:/etc/cron.d$ cat /usr/local/bin/expiry-check.sh |
ssh_shell_request is not a built-in function for Python, and you've not shared the code, so nobody here knows how you're executing those two scripts - my guess is they are NOT being executed as Bash scripts but you're using Bash-specific features.
I haven't actually looked at either script to determine this - too much effort with them formatted as a single line. Python (like Bash) supports multiline strings if you delimit them with """ - you should be making use of that functionality. (Similarly, the formatting of your Bash script is all over the place - such an easy thing to fix and makes a huge difference to readability.) Once you've fixed the formatting, running the scripts through ShellCheck will almost certainly highlight the issues. |
What a horrible way to use Python. Why don't you write it all in Bash?
Quote:
Quote:
Code:
... if [[ $CHECK != 'HEALTHY' ]] ... Quote:
Code:
... if [[ $CHECK ]] ... |
1 Attachment(s)
Hi @boughtonp, thanks for the advise, i managed to clean up the main script, results are looking better after following the spellcheck advise.
|
shruggy & boughtonp
Thanks Guys, main script is already executing without errors, How do i fix the below ones ? Code:
$ shellcheck myscript Code:
$ shellcheck myscript |
ShellCheck cannot check Python. You have to extract Bash code from the scripts and feed only it to ShellCheck.
|
those looks like simple typos for me, although shellcheck cannot check python/awk and other languages:
Code:
$"( should be "$( |
Also, the log file name in your second Python script may be wrong. Judging by your main Bash script, you're generating two log files: 1) user_expiry.txt which only contains one value, password expiration date for a user, and 2) all_user_expiry.txt that contains two columns of data, user email and password age, for multiple users.
I guess that in your second Python script, you'd want to evaluate all_user_expiry.txt rather than user_expiry.txt. That said, Code:
if [[ $DATE -le 10 ]]; then echo 'EXPIRED';... The main script makes a strange impression. There's a striking contrast between a competent use of SQL and a helpless Bash code in the same script. Almost as if those parts were written by different persons. |
All times are GMT -5. The time now is 09:56 PM. |