I’m a total noob in Python, programming and Linux. I wrote a simple python script to track usage time of various apps. I’ve noticed that after some time python is going nuts utilizing 100% of the CPU. Turns out it’s the code obtaining mouse position is causing issues. I’ve tried runnin…
Tag: linux
Using crontab in linux to display a message everytime you open terminal?
I want to display message in terminal: “Welcome!” when someone opens the terminal Answer To print a message when opening a terminal (or logging in via ssh) you should use the message of the day (/etc/motd). You could use cron to overwrite this file at specific times, and so users will see the curr…
Match Anything In Between Strings For Linux Grep Command
I have read the post grep all characters including newline but I not working with XML so it’s a bit different with my Linux command. I have the following data: Using this command cat file.txt | grep -o ‘<tag.*tag>|^–.*’ I get: However, I want the output to be: How can I match any…
Check if any file in a directory contains words in a constant file
i have a directory with n textfiles. Now, i want to check, if any of these files contains one (or more) words of a constant file. These files are all dictionarys with a different amount of words. The constant file is a password list, where i want to check these words. The amount of correct hits should be save…
Error handling of user information in Unix
I need to do some error handling in the beginning of a script. If a user is not a member of a specific group then the script needs to exit. Answer or shorter:
Running a program in linux (debian) on startup
I would like to point out that I tried A LOT of different tutorials from the internet but they don’t seem to work… Adding stuff to init.d, rc.local etc. for some reason it doesn’t work. I’m really desperate to get this done, but I’m a total noob when it comes to linux. when I typ…
How to use cut and paste commands as a single line command?
In Unix, I am trying to write a sequence of cut and paste commands (saving result of each command in a file) that inverts every name in the file(below) shortlist and places a coma after the last name(for example, bill johnson becomes johnson, bill). here is my file shortlist: I am able to cut from shortlist b…
How to exit from shell script if any of the command in SSH returns non-zero value
I have a shell script with below ssh command to perform few actions, Directory $remoteLocation/yyy is not available and it will display the error as, ./test.sh: line 6: cd: /opt/test/yyy: No such file or directory and it is proceeding to the next line. My scenario is to exit from the shell script itself if an…
Unable to parse bash output using regex and collect a part of it
I am trying to parse out the recent load, from the output of this command – The first one after the load average: – I was using this, which worked – However, I realised that the value I am looking for may not always be the 10th variable. Hence I am trying to use regex here, but unfortunately…
python subprocess module hangs for spark-submit command when writing STDOUT
I have a python script that is used to submit spark jobs using the spark-submit tool. I want to execute the command and write the output both to STDOUT and a logfile in real time. i’m using python 2.7 on a ubuntu server. This is what I have so far in my SubmitJob.py script The strange thing is, when I