I am using the savscan command but this returns 3 instead of 1 when a malware is detected, and I need to get 1 if a malware is detected, I tried the following: but I still get the exit code 0, I also need to run everything in one line Answer Personally, I’d use a function wrapper for this: …as
Tag: bash
What would be an optimal way to perform DNS query from bash in python3?
I have this simple bash script that I’m thinking about incorporating into my python project as I couldn’t figure out a graceful way to do this in python3 compared to this single bash oneliner. Is there a better way to do this in python3 or a library that would assist with storing all legitimate un…
zipping all files specified in a text file and then deleting them
I’m trying to add each file, specified one per line, into a file named files.zip. The directory structure of each file specified should remain as is. After the file listed in files.txt is added to files.zip it should be deleted, but never the directories. The structure of the text file is one file per l…
Script in ubuntu to take CPU temperature and CPU usage in the same time and save to file [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago. Improve this question I need to write script or command line code in Ubuntu which take CPU temperature and % of CP…
Makefile generate numerical list of files
I have a Makefile that I use for building a book I am writing into EPUB and Kindle formats. However, my list of source files is getting really long: I am trying to generate this list programmatically, and I got it working with: But can’t help but feel I feel like there is a simpler way. Is there a simpl…
Script exits with error when var=$(… | grep “value”) is empty, but works when grep has results
I have the following bash code (running on Red Hat) that is exiting when I enable set -o errexit and the variable in the code is empty, BUT works fine when the variable is set; the code is designed to test if a screen session matching .monitor_* exists, and if so do something. I have the following turned on: …
Why decrement of variable inside loop returns no success status code?
I can’t understand why inside loop with condition of equal to 0 decrementing of variable returns non-zero status code (not success) if variable was decreased to 0? If I use a different condition for the loop – for example – until [[ $RETR -eq 1 ]] it returns 0 status code after last decreasi…
Using find to rename files recursively with random chars
I have an IP camera that takes snapshots and nests those snapshots into multiple directories. The sub directories look something like this. There is a ton of sub directories because of the way it stores files since it places those snapshots within a Minute directory of the Date/Hour directories. At any rate, …
I have integrated a bash command into my Python code – how can I get this command to take an input from the shell?
I have added a bash command to my Python script – this bash command is used to linearise an input file (i.e. take a file with many lines, and merge it into one line). It works when I manually write the name of the file for the command (in this example, the input file is called input.txt): However, I wou…
Assigning colors to HTML table columns based on conditions
I am using a bash script to send an email in html table format. I have a command like below. Columns are: scenario: When counts are matching then count_validation column will have ‘Matching’ with green color background else red color background. Same way for amounts. What am I missing or doing wro…