lunes, 30 de noviembre de 2015

Server/Box and DB configuration

1) CHARACTERSET deal
Personally I have faced one issue when I was reading directly from a unix box server to be processed and dump into my oracle database. The unmanaged character was ñ so let's detailed the picture.

********* ini text file ****************
esteban|adulto
aidan|niño
chavela|adulta
nana|niña
********* ini text file ****************

2) Run commands using ssh without need login (link, link2)
ssh -t user@example.com "/home/user/bin/detach ls"

unix recipes

1. Transform lines text into one pipeline separated line (link)
echo $VALUES | tr '\n' ' '

2. Crontab
Check this link to create and a tool to automatic generate line in unix

jueves, 25 de junio de 2015

SHELL Script

1.- If
The issue addressed is when is required to test if file is empty. But before that is needed to check if the file exist, I tried this and it worked.

[ -f /etc/hosts ] && echo "Found" || echo "Not found"

2.- Variable empty
Check if a variable is empty before to check if the file path in the variable exist.

if [ -z "$var" ]
then
echo "\$var is empty"
else
echo "\$var is NOT empty"
fi


3.- Convert from ogg to mp3
ffmpeg -i audio.ogg -acodec libmp3lame audio.mp3
And also the script. 
 
 
4. Process a list of files
In this link is showed how
for i in *.txt

5. Execute scripts remotely using a local script
ssh pepito@bigserver.com.pe < ./src/main/resouces/shell_scripts/unix_code.sh
check this link for more details


lunes, 25 de mayo de 2015

Unix commands

1) SORT issue ordering text file lines
Sort  command order file text context based on the characterset established in the server. So to deal with that problem and work with native characters byte we can use LC_ALL=C option at the beginning of the SORT command.
For example if we have the following file

*************begin demosort.txt*********************
ESTEBAN_ALVINO|ealvinoq@gmail.com
ESTEBANALVINO|ealvino@yahoo.com
ESTEBAN_ALVINO|estebana@yahoo.com
*************end demosort.txt*********************

SORT command in my server will order in this way

 $ sort demosort.txt
ESTEBAN_ALVINO|ealvinoq@gmail.com
ESTEBANALVINO|ealvino@yahoo.com
ESTEBAN_ALVINO|estebana@yahoo.com


for other side using LC_ALL=C it will appear as this

$ LC_ALL=C sort demosort.txt
ESTEBANALVINO|ealvino@yahoo.com
ESTEBAN_ALVINO|ealvinoq@gmail.com
ESTEBAN_ALVINO|estebana@yahoo.com

2) UNZIP
In order to avoid system ask for overwrite an existing files when you try to update a folder unzipping a file. use command "o", for example myzip.zip inside the current directory I will try to unzipped for second time because new files were added, with option "u" I only will add new files.
For option "d" check this link
unzip -uo myzip.zip -d .

3) MKDIR (more in this link...)
In order to clone an structure without data I need that mkdir don't fail if parent directory no exist and the command create it by default, the option needed is "p".
mkdir -p bin docs/personal docs/business lib

4) dos2unix alternative
cat mydosfile.txt | tr -d '\015' > myunixfile.txt

5. CP(link)
In order to copy hidden files use "r" option.

6. CPIO(link,link2)
clone/bk folder

7. SCP
lots of smaples (link)

jueves, 5 de febrero de 2015

Watch netflix from fedora 20

In this page you will find all the necessary steps to perform that

Just one thing to add, in my case i had have problems with wine version, so I've desinstalled and installed again using the new repo added that is specified in the link that i leave.

Furthermore, I've installed chrome from this link  and add the addin the the link said and run netflix from them without problems. :)

I've put the sequences of commands I've executed and those are:

1. Install pipeligth-selinux, which is asked as prerequisete to install pipelight
#dnf install ./pipelight-selinux-0.2.1-2.fc21.noarch.rpm

2. As pipelight is in the repository so just execute this
#dnf -y install pipelight


3. For second time in firefox didn't work and it worked in chrome so used the link above for installing chrome and the below to add the addin necessary to play netflix without problem.

https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg