T.CO URL resolver script

2013/10/02 by Lassi A. Liikkanen

T.CO link resolver script

#!/bin/bash
# this script resolves T.CO urls into destination string output
#
# Use:  $tco.link.string
#
#  @lassial Lassi A Liikkanen 1.10.2013 ; first created
#
# License CC3.0 attribution 
#
# requires a local copy of http://curl.haxx.se/ca/cacert.pem to work
# use wget http://curl.haxx.se/ca/cacert.pem to download it


if [[ "$1" == "" ]]
then
        exit 0
else
        result=`curl -silent --cacert cacert.pem  -I -L $1 | grep -i "Location:" | tail -1  | cut -c11-`

        
        if [[ "$result" == https://www.facebook.com* ]]; 
                then 
                        curl -silent --cacert cacert.pem  -I -L $1 | grep "Location:" | head -1  | cut -c11-

                else 
                        echo $result
        fi

fi

Related content:
Several unrelated tips for linux maintenance, 2013/12/08

Command line script to batch rename files in UNIX shell, 2010/01/06

Practical guide to using SSH public key identification, 2008/06/25

No comments for this page
Add comment | Show all comments

Name*:
Email*:
Your email will not be shown publicly or disclosed to third parties, it is used to validate messages
Location (City, Country):
* This information must be provided

Keywords: [unix] , [www-techniques] Document's status: Ok (Document dates explained)

This document created: 2013/10/02
Modified: 2013/10/02
Published: 2013/10/02


This document's permanent URI (linking):
http://iki.fi/lassial/guides/unix/131002-T.CO_URL_resolver_script

© Lassi A. Liikkanen 2013 - 2016. All rights reserved.

*Change layout:
Printable printable
Large text

Myydään:

@lassial Twitter feed: