In this case , it will simply print the line, but if you need to do an operation on the text , just insert your code into the while loop.
If you use a Linux box to display some infos in a public space , you might not have the possibility to connect a mouse and keyboard every time you need to click on the page.
For example, at work we use a TV to display some metrics with grafana,
Sometime, when we reboot the machine , the identification cookie will be outdated and the browser will land on the authentication page instead.
Since the machine has no keyboard and mousse attached this cause some issues , .
So I’ve used the tool xdotool that allow a privileged ssh user or a script to interact with the mouse and keyboard
An important step is to select the screen on witch you want to send mouses clicks and keystrokes.
After that lets say your screen is displaying a full-screen browser with a login page ,
By default the cursor is already in the login form.
for the example , the login/password are going to be admin/admin
you are now logged and you dashboard will display
When you are spending your day in the terminal , you will find that navigating using only the arrows keys although fine at the the start will frustrate you because it’s quite slow.
Bash come with a lot of keyboard shortcuts design to gain precious time.
CTRL+A # will move the cursour to the beginning of the line
CTRL+E # moves to end of line
CTRL+C # halts the current command and back to prompt
CTRL+D # deletes one character backward or logs out of current session, similar to exit
CTRL+K # deletes all the text forward to the end of the line
CTRL+L # clears screen and redisplay the line
CTRL+R # searches history entering keyword ,
CTRL+T # transposes two characters
CTRL+U # kills backward from point to the beginning of line
CTRL+W # kills the word behind the cursor
i’ve put in bold the shortcuts that i use every day , i don’t use CTRL+A and CTRL+E because the keyboard has keys that are foing the same thing.
In bash , it is common to have to do some action on a numéric serie of files , like deleting or renaming ,
Using brace expansion you will be able to générate a single line that will act on multiple targets ,
For our example , let’s think about a list of ten files
in the simple case where i want to delete the complete list of files, i just have to run de command,
The 10 files will be deleted, but , this is not practical if you want to keep the last file , and delete the other nine,
In that case we can use a usefull tool called brace expansion,
To delete the files 1 to 9 , i just have to run in my bash terminal!
This last one is extremely practical , I use it very often in a lot of different uses cases.
But in other cases , you may want to delete even on odd files , or one every three files,
This is also doable with braces expansions
il you need to run a script unattended and wish to log the output of that script you must already know that you can simply do
the problem with that is you will not log the error messages , only the output messages ,
the error are going to be displayed on the terminal but , not logged
and the error message are often as important as the output message , we do not want to dismiss them from the log ,
the solution to that issue is to run the script using this
With this , both the output will be logged in to the log file.
When installing grafana and influxDB. I encountered the folowing issue
The service of grafana and influxDB where not starting .
I checked using rcconf that my service where enabled , and they where !
I then tried sysv-rc-conf and my service where correctly configured !
the services had absolutely no issue starting when called manually and started fine !
this line was telling me that the service startup was disabled !
after seaching a bit on the web ,the solution to this issue is using systemctl to enables the services.
If you have to insert multiples values in an influxdb database. You can use curl and insert the values one at the time.
But there is a better way like in this example
Let’s say you want to insert your tree loadaverage values in you influxdb database.
First put them into variables using these 3 lines.
Then using this curl line, insert them all at once in your influxdb database
One of my project with my OrangePI is to setup the device as a basic IP security camera server ,
the OrangePI zero , will connect to RTSP flux of the IP camera , and dump the stream on to an external disk , where it will be kept for 7 days before getting automaticly deleted
At a latter date i will run a motion detection program on these files and send a mail if motion is detected on a specific part of the frame.
after a little research , i found that a lot of people are using a program called openRTSP to record their RTSP stream to disk
But , after connecting on my OrangePi zero and trying to look for the program i found out that it’s not part of the default installation of armbian stable.
I tried to install the package using apt install openRTSP
I went to google and searched , openRTSP package ,and found out , on the debian website that openRTSP is part of the livemedia-utils package,
I went back to my SSH session and typed apt-get install livemedia-utils
There is no man pages associated with the program , you have to rely on the developer website to understand all the different options . The documentation is available here : http://www.live555.com/openRTSP/ or here if the website is down.
but as usual , in the officials repositories you only get dated version
you might want to compile the source code to have the last version available:
Go to /usr/src: cd /usr/src
Get the live555 liveMedia source code: wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz
Unpack it: tar -xzf live555-latest.tar.gz
Go into the unpacked directory: cd live
Generate the make files: ./genMakefiles linux
Build the code: make
Install the latest version: make install
The issue when you download movies online, is that most of the time the file name is going to be complete trash , filled with useless info like the team that made the rip or the website from where the movie was downloaded.
This is very annoying when you sort by name and the website made the idiotic decision to put their name in front of the actual film name.
for example here a typical movie name
[ Torrent9.info ] Dont.Think.Twice.2016.FRENCH.WEBRip.XviD-NEWCiNE.avi
the actual useful data that i wish to keep is Dont.Think.Twice.2016.avi
for this purpose i’ve developped a small bash script that will list all the files in a chosen directory then , if necessary , will rename the file.
this is not a very efficient script
but it’s fulfill it’s purpose and very rarely encounter a filename that he is unable to clean.