How to configure Jenking without GUI

It is possible to create the jobs in jenkins using Groovy.
You can create a Groovy script file $JENKINS_HOME/init.groovy, or any .groovy file in the directory $JENKINS_HOME/init.groovy.d/, to run some additional things right after Jenkins starts up.

In Ubuntu $JENKINS_HOME is by default configured in /var/lib/jenkins/

Continue reading

Connect Juniper VPN from linux

You can use openconnect to connect to a Juniper VPN:

openconnect --juniper

It will parse the web and will ask you for user/password.

But sometimes this does not work, so you would have to login via web and then copy the cookie DSID:

openconnect --juniper -C "DSID=ab353bbbcd677e8adf5a2f335b6c77ac"


Remove line breaks in CSV

You have a CSV lines with new line breaks and you need one line per entry.


A simple solution could be:
sed ':a;N;$!ba;s/\r\n/ /g' myfile.csv > myfile_no_nline.csv
If the new lines inside the CSV body are Windows new lines (\r\n) and the CSV lines are UNIX (\n).

But normally you are not so lucky. So if your CSV new lines are between quotes (“) you can use the following command:
cat myfile.csv | gawk -v RS='"' 'NR % 2 == 0 { gsub(/\n/, "") } { printf("%s%s", $0, RT) }' > myfile_no_nline.csv

Sharing Internet connection from your Linux

I want to share my Interent connection from my linux to another equipment.

First you have to enable NAT in your linux,
as root you must type:

# iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

Then, logged as root, you have to enable IP forwarding.
There are two ways:

# sysctl -w net.ipv4.ip_forward=1


# echo 1 > /proc/sys/net/ipv4/ip_forward

Now you have to configure in your other device the IP of your linux as default gateway.

And that’s all folks!

If you have problems with iptables and you want to remove all the rules write:

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT

Record screencast in Linux from command line

To record what appears on the screen or in an application you can use the program recordmydesktop 

To record the whole screen use:

$ recordmydesktop -o screencast.ogv

By default it uses a low frame rate and recods audio, If you want to use a higher frame rate without audio:

$ recordmydesktop --no-soundo --fps 24 -o screencast.ogv

Probably you want to record a window application, not the whole screen. To do that you fist need to know the Window id which can be obtained with the xwininfo command:

$ xwininfo 

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1a00003 "5554:intel17"

  Absolute upper-left X:  1467
  Absolute upper-left Y:  122
  Relative upper-left X:  1
  Relative upper-left Y:  32
  Width: 712
  Height: 800
  Depth: 24
  Visual: 0x22
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x1a00010 (not installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +1467+122  -781+122  -781-128  +1467-128
  -geometry 712x800+1466+90

In this case we are trying to record from the Android emulator. I know that for this purpose, if your android emulator version is 4.4 or higher, you can use the following commands over command-line:

$ adb shell screenrecord /sdcard/demo.mp4
$ adb pull /sdcard/demo.mp4

But in this case we are going to record from the host PC. So, if you want to record some part of the window, in our example the window has 480px and the remainder are just window decorators, write the following:

recordmydesktop --no-sound --windowid 0x1a00003 --fps 24 --width 480  -o screencast.ogv