Created
December 26, 2011 04:26
-
-
Save noromanba/1520523 to your computer and use it in GitHub Desktop.
Expand Short URL with Cygwin(prob GnuWin32) - Based on oneliner bash. put stdout(no linebreak)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@rem =========================================================================== | |
@rem Expand Short URL with Cygwin(prob GnuWin32). | |
@rem @author noromanba | |
@rem @license MIT License http://nrm.mit-license.org/2011 | |
@rem @see https://gist.github.com/1520523 | |
@rem @see http://gnuwin32.sourceforge.net/ | |
@rem @see http://ya.maya.st/d/200903c.html#d20090321 | |
@rem @see http://shellscript.sunone.me/filter_etc.html | |
@rem =========================================================================== | |
@echo off | |
cd %~dp0 | |
if "%1"=="" goto :EOF | |
::wget --no-check-certificate -S --spider http://goo.gl/0xP5 2>&1|^ | |
::grep --line-buffered -o -P "Location:\s.*"|head -1|sed -u -r "s/Location:\s//" | |
for /f "usebackq tokens=*" %%u in ( | |
`wget --no-check-certificate -S --spider %1 2^>^&1^|^ | |
grep --line-buffered -o -P "Location:\s.*"^|head -1^|sed -u -r "s/Location:\s//"` | |
) do set XURL=%%u | |
set /p NOLINEBREAK=%XURL%< nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment