Linux programmas en scripts |
Linux programs and scrips |
|
Voor mijn werk ontwikkel ik software in verschillende
(script) talen, bijvoorbeeld Fortran90, python, csh
op verschillende Unix en Linux machines.
Ook voor mijn genealogische hobby komt het geregeld voor dat ik
een stukje codeer om een vraagstuk op te lossen of
een taak makkelijker te maken. Ik publiceer hier enkele scripts/programmas om er zelf gemakkelijk bij te kunnen als ik ze nodig heb, en wellicht heeft een ander er ook wat aan. Mocht er iets nuttigs voor u tussen zitten gebruik het dan gerust voor eigen gebruik. Hier geldt de gebruikelijke disclaimer dat ik niet kan garanderen dat alles werkt zoals bedoeld op andermans computer. Gebruik is dus geheel voor eigen risico. Verder verspreiden is prima wat mij betreft onder de voorwaarden van de GPL. Mocht u een andere licentie willen gebruiken neem dan eerst even contact met me op. |
Professionally I develop software in several (script) languages,
for example Fortran90, python, csh on different Unix and Linux
systems.
Also for my genealogy hobby it happens rather often that I
write some code to solve a problem or make a job easier. Here I make some scripts/programs available, first to have easy access to them myself when needed. Also maybe somebody else finds them usefull. In case you find some of them usefull, feel free to use them for personal use. Ofcourse the usual disclaimer holds, which is that I cannot give any guarantee that this software will functon as intended on unknown platforms. Using them is completely at your own risk. You may redistribute the software if you like, using the conditions of the GPL. In case you would like to use any other license then please contact me first. |
Python scripts |
|
|
een statische website onderhouden: Een python script om mijn statische website te synchroniseren met een locale copie. In de bijgevoegde settings file kun je details mbt website adres, wachtwoord e.d. invullen. |
update static website: A python script to synchronise my static website with a local copy. The included settings file can be used to fill in details like website address, password, etc. |
|
spaties verwijderen: Spaties en quotes in file en directory namen kunnen erg irritant zijn als je een script wilt gebruiken op een linux/unix machine. Dit kleine python script vervangt ze door underscores. |
remove spaces: Spaces and quotes in file and directory names can be very annoying if you try to script things on linux/unix systems... This little python script replaces all spaces and quotes in the file and directory names in the current directory by underscores. |
|
filenaam naar kleine letters: Onbedoeld kun je soms een mix hebben van hoofdletters en kleine letters in je filenamen. Dit kleine python script converteert alle karakters in de naam naar kleine letters. |
filename to lowercase: Sometimes you have an unintentional mix of upper and lower case characters in your file names. This little python script converts all characters in the filenames to lower case. |
|
repareer regel einde: Een ander irritant probleem dat soms voorkomt is de line-end conventie. Zoals bekend verschilt die voor linux/unix, windows/dos en mac machines, en zeker als door knippen en plakken een mix van conventies is ontstaan kan het lastig zijn een file bruikbaar te maken. Dit python script converteert alles naar de linux conventie, maar is simpel aan te passen als je een andere conventie nodig hebt. Het toepassen van het script op bijvoorbeeld een subdirectory met fortran files kan met het volgende commando: |
fix line-ends: Another irritating probleem that somtimes occurs is the line-end convention. This differs for linux/unix, windows/dos and mac machines, and sometimes it happens (for example through a cut-and-paste action) that a file holds a mix of conventions which makes it really hard to use the file. This python script converts all lines to the linux convention, but it should be simple to adapt it ion case you need it on another platform. To apply this script for example to all fortran files in a given directory tree, you could use a command like this: |
find ./*/*.F90 -exec ~/bin/fix_line_ending.py {} \;
|
|
|
Pas recursief file permissies aan: Het recursief aanpassen van permissies van alle files onder een gegeven pad kan simpel met het "chmod -R" commando, maar soms kan dit erg lang duren en enorm veel waarschuwingen opleveren. Dit gebeurt bijvoorbeeld als het pad symbolische links bevat naar een plaats waar je geen schrijf permissie hebt. Dit python script doet hetzelfde, maar slaat automatisch alle symbolische links over (en kan eenvoudig aangepast worden om bepaalde soorten files, filenaam patronen of directories uit te sluiten). |
Change file permissions recursively: Changing permissions for all files recorsively below a given directory is easy using the "chmod -R" command, but sometimes this can take a long time and cause huge amounts of warnings, for example if the directory holds symbolic links to places for which you have no write permission. This python script does the same, but automatically scips all symbolic links (and is easily adapted to exclude certain file types, patterns, directories, etc.) |
|
Pas een xml bestand aan vanaf de commandline: Dit python script maakt het mogelijk een xml file eenvoudig aan te passen vanaf de commandline. Erg handig als je enkele elementen uit een xml file wilt wijzigen vanuit een ander script. In tegen stelling tot sommige andere tools, probeert dit script zoveel mogelijk de line-ending en de layout van de bestaande xml file over te nemen en te handhaven, zodat verschillen gemakkelijker met het standaard diff commando bekeken kunnen worden. Hieronder volgt een voorbeeld van het gebruik van dit script: |
Modify xml files from the commandline: This python script allows you to modify an xml file in a simple way from the commandlines. Very convenient is you wish to automate modifications of xml files from within a script. Unlike some other tools, this script tries to keep the line-ending and layout of the existing xml file as it is, which allows use of the standard diff diff command to inspect the applied changes. Below you see an example of how this script can be used: |
XmlModify.py somexmlfile.xml \
/RootTag/Data/Value1 blabla XmlCreateNode \
/RootTag/Data/Value1 abcdefg XmlEditNode \
/RootTag/Data/Value1 1234567 XmlAppendToNodeValue \
/RootTag/Data/Value1 Value2 XmlChangeNodeName
|
|
csh scripts |
|
|
Maak een pdf boekje mbv jpg bestanden: Een klein csh script om een boekje in pdf formaat aan te maken van een verzameling scans in jpg formaat. Dit is het script waarmee ik dit boekje gemaakt heb. Het gebruikt convert (onderdeel van de ImageMagick tools) en gs (GhostScript). |
Create a pdf booklet from jpg files: A little csh script to create a book in pdf format using a collection ofscans in jpg format. This is the script I used to create this little book. It uses the convert tool (part of the ImageMagick tools) and gs (GhostScript). |
|
De inhoud van een rpm file bekijken: Soms is het nuttig een rpm file te kunnen uitpakken om te zien welke files en scripts er in zitten. Dit kleine shell script kan hiervoor worden gebruikt. |
Look at the content of an rpm file: Somtimes it can be very usefull to manually unpack an rpm file, to be able to look at the files and scripts contained in it. This little csh shell script can be used to do this. |