18.01.2020 Views

Working with Linux

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Save the script, and let's test it.

First, let's get the interface name from the ifconfig command, and then let's go and test the script by

running this command:

iputil --cmd ip --iface wlp3s0

We can see it's printing our private ip on the screen.

Now let's add our last cmd to the script: publicip.

For this we just call the get_public_ip function from our lib utility. Save it and run this:

iputil --cmd publicip

We see that the command worked; our public ip is printed on the screen. Here is the complete script:

#!/bin/bash

CWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )

cd ${CWD}

source ${CWD}/lib.sh

CMD=$(getarg cmd $@)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!