A következő címkéjű bejegyzések mutatása: shell script. Összes bejegyzés megjelenítése
A következő címkéjű bejegyzések mutatása: shell script. Összes bejegyzés megjelenítése

2020. május 29., péntek

PDF fájl átalakítása Wiki formátumra

sudo apt install pandoc
sudo apt-get install poppler-utils

PDF --> HTML
sudo mkdir kimenet
sudo pdftohtml -s -p -fmt png -nodrm "file.pdf" "file/file.html"

You can type pdftohtml -h to gain a better understanding of available parameters.
I've explained the parameters used here for the sake of understanding the command:
  • -s contains all of the output within one HTML document (excluding the outline.
  • -p attempts to replaces pdf internal linking with html links.
  • -fmt controls the output format of images, with png and jpg being valid options.
  • -nodrm igores download rights management restrictions on the PDF.
  • -i ignores images. I didn't use this, but it felt prudent to mention as in some cases it may massively speed your output format.

Alternatív módszer: Poppler pdftotext

pdftotext -htmlmeta "file.pdf" "file.html"

 Replace "file" with the name of the file you want to parse and with the name of the HTML file you want to write your text output to. 
 The `-htmlmeta` option creates an HTML version of the text in your PDF. (This is much less fancy than the previous command and only puts the text in `pre` tags). You should see an HTML file in your directory which you can open to check the results of. Depending on the formatting of your source PDF file, you may find that Poppler is variable in it's effectiveness. You can try running `pdftotext -h` for information on other command options that may improve or worsen your results. 

Pandoc: HTML --> MediaWiki

 pandoc file.html -f html -t mediawiki -s -o file.txt
  • -f bemeneti formátum
  • -t kimeneti formátum
  • -s Standalone adds a header and footer to the document, rather than producing a document fragment.
  • -o The name of the output file.
Pandoc user guide.
It is possible you may run into an error with Pandoc, presumably caused by your file being too large. I ran into this error and some fixes can be found here.

Opció: rossz kódolás kitakarítása

Depending on your PDF encoding, you may find strange Unicode charecters in your HTML output. This step is intended to clean up this output to the best possible degree of accuracy. ftfy, stands for fixes text for you, and it's a Python library with a command-line interface. We'll be using the command line to clean our files. This step is preformed before using Pandoc.

ftfy telepítése:
git clone https://github.com/LuminosoInsight/python-ftfy.git
cd python-ftfy
sudo python setup.py install
Or, if you system has pip, pip install ftfy. Note that if you want to use a version of 5.0 (most recent available at time of writing) or later, you need Python 3. I used Python 2.x with ftfy 4.1.1 for this answer. Using the same directory, type the following command:
 ftfy -o file_clean.html --preserve-entities file.html
Optionally, you may include the --guess option to have ftfy guess your encoding, or --encoding if you know your encoding. This may produce better results.

2015. október 3., szombat

Programok processzorhasználatának korlátozása Linuxon

EN: How to Limit The CPU Usage of Any Process in Linux
Do your applications eat up all the CPU resources causing overheat? Not anymore with cpulimit:
https://github.com/sicambria/sh/blob/master/system/cpulimiter.sh

Edit:
BES should do something similar on Windows:
http://mion.faireal.net/BES/

2015. május 24., vasárnap

Convert MP3 to OGG with AVCONV

/usr/bin/avconv -y -i "input.mp3" -acodec libvorbis -b:a 256k  -vol 256 "output.ogg"

-vol kapcsoló: hangerő állítása:
128: fele hangerő
256: nincs változás
512: kétszeres hangerő

2014. november 2., vasárnap

PDF dokumentumokból szöveg készítése (OCR) Linuxon

EN: How to OCR any PDF file on Ubuntu Linux with pdftoppm, convert and tesseract

#!/bin/sh
mkdir tmp 2>/dev/null
cp $@ tmp
cd tmp
clear
echo
echo "Processing $@..."
pdftoppm *.pdf -f 1 -l 100 -r 600 ocrbook 2>error.txt

for i in *.ppm; do
echo "CONVERT: $i"
convert "$i" "`basename "$i" .ppm`.tif"; done

for i in *.tif; do
echo "OCR: $i"
# -l hun  -->> OCR for HUNGARIAN LANGUAGE
tesseract 1>/dev/null 2>error.txt "$i" "`basename "$i" .tif`" -l hun; done
for i in *.txt; do cat $i >> pdf-ocr-output.txt; echo "\n[$1]\n" >> pdf-ocr-output.txt; done
mv pdf-ocr-output.txt ..

# Cleanup
mkdir text 2>/dev/null
mv *.txt text 2>/dev/null
rm * 2>/dev/null
cd ..
#rmdir tmp


Original source (script was modified):
http://ubuntuforums.org/showthread.php?t=880471

2014. július 20., vasárnap

Ubuntu 14.04 LTS software installer and config shell script

#!/bin/sh

echo "Install common GNU/Linux applications to Ubuntu"
cd
cd Letöltések
cd Downloads

#+SYSTEM
sudo apt-get install -y gmountiso p7zip rar lame xfburn
sudo apt-get install -y krusader kdiff3 krename
sudo apt-get install -y gnome-system-tools bleachbit gparted

# HDD
sudo apt-get install -y preload shred srm

# HU
sudo apt-get install -y language-pack-hu language-pack-gnome-hu language-pack-hu-base language-pack-gnome-hu-base

#+OFFICE
sudo apt-get install -y libreoffice-presentation-minimizer libreoffice-l10n-hu aspell-hu hunspell-hu aspell-en hunspell-en-us

#+MEDIA
sudo apt-get install -y vlc phatch nautilus-image-converter audacity picard puddletag gimp

# Skype telepítése
#Ubuntu - enable "partner" repository
#sudo sed -i "/^# deb .*partner/ s/^# //" /etc/apt/sources.list
#sudo apt-get update
#sudo apt-get install -y skype

#  Skype honlap - Website:
#http://www.skype.com/hu/download-skype/skype-for-linux/downloading/?type=ubuntu64
wget get.skype.com/go/getskype-linux-beta-ubuntu-64 -O skype.deb
sudo apt-get install -y gdebi
sudo gdebi --n skype.deb

# Skype magyar nyelvi fájl telepítése
wget http://urbalazs.hu/blog/uploads/skype_hu_4.3.0.37.tar.gz
sudo tar -C /usr/share/skype/lang -xzf skype_hu_4.3.0.37.tar.gz

# Audex Hang CD átalakító program  - Audex CD ripper application:
sudo apt-get install -y audex

# Nem szükséges programok eltávolítása -  Remove unneeded apps - OPTIONAL
sudo apt-get purge -y brasero

# Install Chromium + default incognito mode
sudo apt-get install -y chromium-browser
sudo perl -pi -e 's?Exec=chromium-browser?Exec=chromium-browser --incognito?g' /usr/share/applications/chromium-browser.desktop

# Védett mód - protected mode
# http://sourceforge.net/projects/firejail/files/firejail/
sudo perl -pi -e 's?Exec=chromium-browser?Exec=firejail chromium-browser --incognito?g' /usr/share/applications/chromium-browser.desktop

#+Google Chrome
sudo deb http://dl.google.com/linux/deb/ stable non-free main
sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

# Run Windows applications - Office 2003/2007/2010, Total Commander, Photoshop, games, etc...
# See AppDB: https://appdb.winehq.org/
yes | sudo add-apt-repository ppa:ubuntu-wine/ppa

# Ubuntu Tweak telepítése
yes | sudo add-apt-repository ppa:tualatrix/ppa

# INSTALL FROM EXTRA REPOSITORIES
sudo apt-get update
sudo apt-get install -y google-chrome-stable
sudo apt-get install -y ubuntu-tweak
sudo apt-get install -y playonlinux winetricks wine1.7

# Apport letiltása - megszűnnek a bosszantó rendszerösszeomlás-jelentések
# Disable apport - remove annoying system crash messages
sudo perl -pi -e 's/enabled=1/enabled=0/g' /etc/default/apport

# Swap only after 90% RAM is full
echo "vm.swappiness = 10" | sudo tee -a /etc/sysctl.conf

# END OF AUTOMATED PART
exit 0

# Wifi hotspot: Ethernet kapcsolat + Wifin internet megosztás:
# sudo perl -pi -e 's?mode=infrastructure?mode=ap' /etc/NetworkManager/system-connections/wifi-hotspot
# [ipv4]
# method=shared


# Szoftver tárolók könnyű hozzáadása
# Add repositories easily:
sudo apt-get install -y python-software-properties

# Krita képszerkesztő és digitális festőprogram - Krita image editor and digital painter
yes | sudo add-apt-repository ppa:kubuntu-ppa/backports 
sudo apt-get update
sudo apt-get install -y krita

# e.g. install MUMBLE VoIP client:
yes | sudo add-apt-repository ppa:mumble/release
sudo apt-get update
sudo apt-get install -y mumble

# SWF fájlok megnyitása böngészőben - Play SWF files in browser
sudo perl -pi -e 's?<mime-type type="application/vnd.adobe.flash.movie">?<mime-type type="application/x-shockwave-flash">?g' /usr/share/mime/packages/freedesktop.org.xml
sudo update-mime-database /usr/share/mime

# Installing MATE in Ubuntu 14.04 LTS
yes | sudo apt-add-repository ppa:ubuntu-mate-dev/ppa
yes | sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install --no-install-recommends ubuntu-mate-core ubuntu-mate-desktop

# TEAMVIEWER - Távsegítség program telepítése - REMOTE HELP
wget http://download.teamviewer.com/download/teamviewer_i386.deb
sudo apt-get install -y gdebi
sudo gdebi --n teamviewer_i386.deb


Install latest Xfburn CD/DVD writer on Linux from source - Ubuntu 12.04

How to install Xfburn CD/DVD writer - Tested on Ubuntu 12.04 LTS x64
Xfburn linuxos CD/DVD író alkalmazás telepítése forrásból
Download source:
http://goodies.xfce.org/projects/applications/xfburn
Unpack.
Install dependencies - run these commands from the Terminal:

sudo apt-get install intltool libburn* libisofs* libgtk2.0-dev  libxfce4ui-1-* exo-utils* libexo-1-*

Usual installation:
cd into_unpacked_xfburn_src_directory
./configure
sudo make
sudo make install



2014. május 7., szerda

Install Photoshop CS6 on Ubuntu 14.04 x64

Install Photoshop CS6 on Ubuntu 14.04 x64

- Open the Terminal and type:

sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7 winetricks

winetricks atmlib gdiplus msxml3 vcrun2005 vcrun2005sp1 vcrun2008 fontsmooth-rgb gecko
- Start the installer:

cd [PS-Install-Directory]
wine setup.exe

- If installer fails, try the 32-bit wineprefix:

mv ~/.wine
~/.wine
_backup

WINEARCH=win32 WINEPREFIX=~/.wine winecfg

winetricks atmlib gdiplus msxml3 vcrun2005 vcrun2005sp1 vcrun2008 fontsmooth-rgb gecko 


cd [PS-Install-Directory]
wine setup.exe 

2014. március 15., szombat

Fájlok biztonságos törlése Linuxon a shred+srm paranccsal - Secure delete/wipe files on Linux with the shred+srm command

sudo apt-get install secure-delete

export PATH=$PATH:~/scripts

Create script in ~/scripts

#!/bin/bash

if [ $1 ]
then
    echo "Target folder given: $1"
    FOLDER="$1"
    cd $1 2>/dev/null
    if [[ $? -eq 1 ]]
    then
        echo "Target folder does not exist, exiting!"
        exit 1
    fi
else
    echo "Targeting current directory."
    FOLDER=`pwd`
fi

echo
echo $FOLDER
read -p "CAUTION! Are you sure to shred this entire folder? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
    echo
    ls
    echo
    echo "ALL FILES HERE and also in SUBDIRECTORIES WILL BE ERASED!"
    echo $FOLDER
    echo "--------------------------------------"
    read -p "!!! - CONFIRM AGAIN (capital Y/N) " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Y]$ ]]
    then
        if [[ -e $1 ]]
        then
             find "$1" -type f -execdir shred -uvzn 3 '{}' \;
             srm -sR "$1"
        else
             find . -type f -execdir shred -uvzn 3 '{}' \;
             srm -sR .
        fi
    else
        echo "Exiting, no action."
        exit 1
    fi
fi

2013. december 1., vasárnap

If thumbnails don't work in Nautilus (Ubuntu)

Set show thumbnails in Edit/Settings/Preview to always, under 10 MB, and run these two commands if they don't show up:

mv ~/.thumbnails ~/thumbnails
ln -s ~/.cache/thumbnails ~/.thumbnails

That's it! :)

2013. június 29., szombat

Felesleges DokuWiki nyelvi fájlok törlése (bash/shell script):

EN: Remove unwanted language files from DokuWiki folders (bash/shell script)

Célszerű meghagyni az angol fájlokat, mert egyes szövegek lehet, hogy nincsenek lefordítva: -not -path "*en"

cd dokuwiki-YOUR_VERSION/lib

$ find . -type d -path "*lang/?*" -not -path "*hu" -not -path "*en" -exec rm -r "$1" '{}' \;

2013. április 2., kedd

Fotók rendezése EXIF információk alapján

Használat:

sudo apt-get install imagemagick
csop-exif-lite.sh /media/lemez/FOTOMAPPA/

#!/bin/bash
# Bash script to automatically sort photos into folders based on EXIF data for Ubuntu Linux - Lite version by GW (v2013-04-02)
# Original script source:
# http://mikebeach.org/2011/12/10/bash-script-to-automatically-sort-photos-into-folders-based-on-exif-data-for-ubuntu-linux/
# ----------------------------------------------------
# Warning! This script is just a PoC, use with care!
# ----------------------------------------------------

TARGETFOLDER="$1"
if [[ "$TARGETFOLDER" == "" ]]; then
    echo "Please specify the target (source) folder to sort."
    exit
fi

FILETYPES=("*.jpg" "*.jpeg" "*.png" "*.tif" "*.tiff" "*.gif" "*.xcf")

for x in "${FILETYPES[@]}"; do
 # Check for the presence of imagemagick and the identify command.
 # Assuming its valid and working if found.
 I=`which identify`
 if [ "$I" == "" ]; then
     echo "The 'identify' command is missing or not available."
    echo "Is imagemagick installed?"
    exit 1
 fi;

 echo "Scanning for $x..."
 # FIXME? Eliminate problems (if any) with unusual characters in filenames.

cd $1


result=`echo $1 | tail -c 2`
if [[ "$result" != "/" ]]
then
    echo "Trailing / (slash) required for path! Exiting."
    exit 1
fi


mkdir $1other
mkdir $1bin

 for file in `find $1 -maxdepth 1 -iname "$x"`; do
    #  echo "Item is: $file"
     
    identify -verbose $file | grep "exif:DateTime:" | awk -F\  '{print $2}' | sed s/:/-/g | { read mydate;
    if [[ $mydate == "" ]];
    then
        mv -i "$file" "$1other" ; echo "MOVE $file TO $1other " ;
    else
        mymonth=`echo "$mydate" | cut -c 1-7` ; echo "--- Month: $mymonth " ; mkdir $1$mymonth 2>/dev/null ;
        echo " DATE: $mydate MOVE ITEM: $file TO: $1$mymonth/$mydate ";
        mkdir "$1$mymonth/$mydate" 2>/dev/null ; mv -i "$file" "$1$mymonth/$mydate";

        if [[ $? -ne 0 ]];
            then mv -i "$file" "$1bin"; echo "MOVE $file TO $1bin " ;
        fi ;

    fi ; } 
      done
 echo "... end of $x"
done;

Convert MP4 videos to XVID AVI with avconv (ffmpeg)

MP4 videók XVID AVI formátumra konvertálása Linux terminálból:


avconv -y -i 'input.mp4' -threads auto \
-c:v mpeg4 -q:v 5 -vtag XVID -f avi -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 \
-c:a libmp3lame -ac 2 -q:a 3 -ar 44100 \
"output.avi"

Ezek a csomagok is kellhetnek:

sudo apt-get install libavcodec53 
sudo apt-get install libmp3lame0
sudo apt-get install ubuntu-restricted-extras

2012. május 31., csütörtök

Adobe Flash for Firefox and Chrome on Ubuntu

Quick install:


Download the latest Flash .tgz from Adobe

Unpack the .tgz

Open the Terminal and enter:
sudo mv libflashplayer.so /usr/lib/mozilla/plugins/libflashplayer.so
sudo mkdir /opt/google/chrome/plugins
sudo cp /usr/lib/mozilla/plugins/libflashplayer.so /opt/google/chrome/plugins

Restart browser and that's it.

2011. szeptember 17., szombat

Batch image resize and watermarking shell script

#!/bin/bash

WATERMARK="watermark700.png"
resize=2000

#Choices include: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast.
WATERMARKPOS=SouthEast

OPACITY=60
QUALITY=85

DIR="."

# "*****************************************"
# "* Image Resize and Watermarking Script  *"
# "*         By Krutant.com                *"
# "*        With some tweaks...            *"
# "*****************************************"

clear

echo
echo "This script will OVERWRITE the source files, so work on a copy!"
echo

if [ $# -eq 1 ]
then

    #-----if there is a parameter----
    DIR="$1"
    echo "Target directory: $DIR"

    else

    echo -n "No parameter, current directory is: "
    pwd
    echo

fi


read -p "Watermark with file \""$WATERMARK"\" & resize all images to width "$resize"? (y/n)  " prompt

if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]

then

 echo ""

 shopt -s nullglob


 for each in $DIR/*{.jpg,.jpeg,.JPG,.JPEG}

 do

  echo -n "Working on "$each" ..."

  convert -resize $resize "$each" "$each" >> /dev/null

  composite -gravity $WATERMARKPOS -quality $QUALITY -dissolve $OPACITY $WATERMARK "$each" "$each" >> /dev/null

  echo "[Done]"

 done


# ---

  echo ""

  read -p "Press Enter to exit ..."

else

 exit 0

fi

2011. július 27., szerda

If Ubuntu 11.04 installer fails / freezes at the very end of the installation

No user to log in / Empty user list
Ubuntu 11.04 telepítés megszakad a legvégén
Üres felhasználói lista

--- BOOT FROM LIVE CD/USB ---

1. Install GRUB2
http://www.webupd8.org/2011/06/boot-repair-fix-ubuntu-boot-issues.html

2. CREATE USER

Open Terminal

To list all volumes type:
>mount

Search for the target HDD UUID:
for example: 550e8400-e29b-41d4-a716-446655440000 (it will be different from this)

>chroot /media/550e8400-e29b-41d4-a716-446655440000/

>adduser somebody

RESTART

Log in with the previously created user
Open Terminal
Type:
>sudo su
>passwd
Enter new root password

Make yourself administrator at System/Administration/Users and groups.
Make sure everything is OK, language, encodings, time zone, etc.

Thx for help: dr-willis, nyu at #Ubuntu IRC