Posts Tagged ‘Windows’

App-Fu: VLC Plays Youtube Clips

Thursday, August 12th, 2010

VLC 1.1.x accepts youtube urls in its “Open Network Stream…” dialog.

It’ll opt for the highest resolution available, so if you want to force a less taxing quality, add this to your url.

http://www.youtube.com/watch?v=yadda&fmt=5

This means you can save it to a file without a separate downloader tool/site. And/or you can watch at 2x speed or crank up the volume to 400% with the mouse wheel. Unless you save before watching, it’s subject to buffering, so seeking is best avoided.
 
 
It relies on an external script to scrape the page and fetch the video. That’s what needs fixing when youtube’s site changes.

VLC_Dir\App\vlc\lua\playlist\youtube.lua

Judging from the dir listing, several other sites are understood too.

Sed One-Liner to Mass-Rename

Tuesday, July 20th, 2010

Linux’s perl package has a command called “rename” which understands regular expressions.

Windows lacks that, of course. I’ll recreate it using sed, in a way that’s consistent across platforms…

It won’t spring to mind when you need it (unless you’re really familiar with sed), but the exercise is a decent excuse to demonstrate the oft-neglected hold buffer.
 
(more…)

RancidMeat: Grub4Dos

Monday, July 19th, 2010

Delayed whim I followed up on this week: a fork of GNU Grub.*

Once I settled on one of the myriad riggings that clutter the docs, it was easy to set up from within Windows. No Linux necessary.
 
(more…)

Peek at Pipes by Copying Stdout to Stderr

Wednesday, May 5th, 2010

I’m stringing commands together and want to see what’s passing through a particular point. Technically tee (Linux/UnixUtils) can do this. Its sole purpose is to duplicate stdout to a file, like a metaphorical “T” connector.

echo hello | tee somefile.txt | sed "s/e/a/"

 
Attentive readers will be thinking,
“The post just started; what’s wrong with it?” :P
 
*clickety-click*… Nothing, this works:

echo hello | tee /dev/stderr | sed "s/e/a/"

 
*drumroll*… on Linux, where everything’s a file.

While many MinGW ports on Windows internally translate the likes of “/dev/stderr”, the UnixUtils tee does not. A hyphen arg obediently makes a file named “-”. Linux guys can keep reading; this trick is nifty.
 
(more…)

App-Fu: Viewing Compressed Traffic in Wireshark

Friday, April 30th, 2010

According to the preferences, the three sections of Wireshark are:

  • Packet List – Rows of src/dest/protocol/info
  • Packet Details – Collapsible tree
  • Packet Bytes – Tabbed hex dumps

Most of the time, if you’re sniffing text-based traffic, you’ll find interesting packets, right-click in the list, and “Follow TCP Stream”. The problem is Wireshark’s too honest sometimes, and if the traffic is compressed, you’ll see the binary garbage that’s really flowing through the NIC.

HTTP/1.1 200 OK
Content-Encoding: gzip

If you see this HTTP header, there’s another approach.
 
(more…)

RancidMeat: XMLStarlet

Monday, April 26th, 2010

Occasionally I have to parse xml, which is often not grep-friendly. Luckily, there’s XMLStarlet (the actual command’s named ‘xml’) to make it relatively easy, if longwinded for a prompt. It’s in Linux repositories, and there’s a Windows version.

For this post, I’ll be referring to an example file that looks like this.

<?xml version="1.0"?>
<Cast>
<Character gender='M'>
  <Name>Fry</Name>
  <Job>Delivery Boy</Job>
  <Species>Human</Species>
  <From>
    <Location>Earth</Location>
    <Location>New York</Location>
    <Location>Brooklyn</Location>
  </From>
</Character>

</Cast>

 
 
1) Loop through all characters, printing the value of their name tag and a newline.

xml sel -t -m "/Cast/Character" \
-v "Name" \
-n futurama_cast.xml

# Zapp
# Leela
# Amy
# Zoidberg
# Fry
# Bender
# Professor
# Kif

 
(more…)

Batch For Loop Over a List

Thursday, April 15th, 2010

Say you’ve got a Windows command to run over and over with a different arg each time. Wouldn’t it be nice if you could make a word list and loop over it the way bash does?
 
(more…)

Echoing Multiple Lines into a Pipe

Monday, March 29th, 2010

If you’ve been batch scripting on Windows for a while, you probably know the way to echo a blank line: a period with no space in front of it.

echo.

And the way to chain commands together:

  • A || B runs B if A failed
  • A && B runs B if A succeeded
  • A & B runs B regardless

It may not be obvious, but you can echo multiple lines into a pipe without resorting to a temp file.

(echo def& echo abc) | sort

You will have to butt the ampersand against the end of each echo, or you’ll be sending spaces at the end of each line.

If you make a lot of lines, mashing them together gets hard to read. The solution to that obscure situation is below.
 
Edit (2010-04-25): Argh! Ampersand butting works for redirecting to a file, and FOR loops (as you’ll see in a later post), but plain ol’ pipes still get trailing spaces!
Example: Pipe into sort, get spaces. Dump to tmp.txt, no spaces.
My “Right Way”, below the fold, somehow only got a space on the final line.
 
(more…)

RancidMeat: Ncat

Sunday, February 14th, 2010

Netcat is reaaallly handy for piping stuff over networks. But it’s also been largely unchanged for years. There were a few forks and rewrites but they tended to be linux-only. One of the tricks it could do was ip/port scan. Scanning happened to be the primary function of the Nmap project, and so it grew to incorporate netcat features, and much more. Behold Ncat!
 
Edit (2010-08-03): 5.35DC1 made “-l -e” exit on disconnect, and “-l -e -k” keep awaiting new connections.
Edit (2010-03-16): I announced app this too early. 5.30b1 corrected the piping bugs I mentioned before. However, combining -l and -e still makes a server that never dies on its own (acts like -k), and must be killed manually. That might be fixed in a later release.
 
(more…)

RancidMeat: Mini SFTP Server

Wednesday, January 20th, 2010

screenshotCoreFTP is a shareware client/server suite. However there is also a freeware server half-way down this page.
 
It’s dead simple to use: double-click, make up a user/pass, click start.

(more…)