Tag Info

Hot answers tagged

14

There are many different versions of mail around. When you go beyond mail -s subject to1@address1 to2@address2 <body (for sending, that's all POSIX guarantees — and even -s didn't exist in the old days), they tend to have different command line options. Adding an additional header isn't always easy. With some mailx implementations, e.g. from mailutils ...


10

The html-xml-utils package, available in most major Linux distributions, has a number of tools that are useful when dealing with HTML and XML documents. Particularly useful for your case is hxselect which reads from standard input and extracts elements based on CSS selectors. Your use case would look like: hxselect '#the_div_id' <file You might get a ...


7

You can do this with mutt's mime support. In addition, you can use this with Autoview to denote two commands for viewing an attachment, one to be viewed automatically, the other to be viewed interactively from the attachment menu. Essentially, you include two options in your mailcap file1. text/html; text/html; luakit '%s' &; test=test -n "$DISPLAY"; ...


5

Though this goes against my better judgment I'll post it (sed part). That is: if it is for a quick and dirty fix go ahead. If it is a bit more serious or something you are going to do frequently etc. Use something else like python, perl etc. where you do not rely on regular expressions, but rather modules to handle HTML documents. One of the simpler ways ...


4

The perl CGI module has a escapeHTML function that makes it pretty easy: perl -e 'use CGI qw(escapeHTML); print escapeHTML("<hi>\n");' Or to do an entire file: perl -p -e 'BEGIN { use CGI qw(escapeHTML); } $_ = escapeHTML($_);' FILENAME


4

The debian package dwww give access to all the documentation installed by the packages, included the manual pages. After installing the package with your favorite package manager, you will be able to browse the local documentation with your navigator on http://localhost/dwww/. By default, access to this URL is restricted to local connections but you can ...


4

You need to make it a multipart/mixed message, boundaries and all. ( cat <<EOCAT MIME-Version: 1.0 From: $from To: $to Cc: $cc Subject: TEST email w/ HTML Content-Type: multipart/mixed; boundary=NextPart_0123456789 Content-Transfer-Encoding: 7bit --NextPart_0123456789 Content-Type: text/html EOCAT cat header.html cat html_message_body.html cat ...


4

You may want to take a look at the Uzbl browser. It's a minimalist web browser based on webkit (the layout engine used by Chrome/Chromium). According to the definition, it's a collection of "web interface tools which adhere to the unix philosophy". It comes in 3 flavors: uzbl-core uzbl-browser uzbl-tabbed The latter 2 are finished products and ...


4

As you've discovered, this method is suboptimal at best. In addition to the HTML you'll need at a minimum all images and CSS. You may also need all of the Javascript. And then there's the whole deal of rendering this mess. But for you there is good news in the form of a Command Line Printing extension you can install in Firefox. Then: firefox -print ...


4

It sounds like you're looking for a very crude form of revision control. You'd do better to look into using a VCS like git. Once you've got git installed, it's fairly simple to do what you want: git init # Initialise the new repository # ... change some files ... git add file1 file2 # Add files to context git commit -m 'Changed something' ...


3

One way using perl with the help of the XML::Twig parser: #!/usr/bin/env perl use strict; use warnings; use XML::Twig; use File::Spec; my $twig = XML::Twig->new( twig_handlers => { ## For each 'img' tag execute following function... 'img' => sub { ## If it doesn't have an 'alt' attribute... if ( ! ...


3

You do have a requirement that warrants an HTML parser: you need to parse HTML. Perl's HTML::TreeBuilder, Python's BeautifulSoup and others are easy to use, easier than writing complex and brittle regular expressions. perl -MHTML::TreeBuilder -le ' $html = HTML::TreeBuilder->new_from_file($ARGV[0]) or die $!; foreach ($html->look_down(_tag ...


3

You want to use pptHTML: http://www.ma.utexas.edu/restricted-resources/utma-doc/xlHtml/pptHtml.txt For debian based distros: http://packages.debian.org/unstable/utils/ppthtml The C Source for the xlhtml package: http://prdownloads.sf.net/chicago/xlhtml-0.4.9.3.tgz ppthtml is an executable installed through the same package.


3

This is a huge hack, but somebody has already done the work for you. Edit: What if you attached your signature as an HTML file? mutt -e "set content_type=text/html" someone@somewhere.com -s "Hello" < mysig.html


3

Here's an untested Perl script that extracts <div id="the_div_id"> elements and their contents using HTML::TreeBuilder. #!/usr/bin/env perl use strict; use warnings use HTML::TreeBuilder; foreach my $file_name (@ARGV) { my $tree = HTML::TreeBuilder->new; $tree->parse_file($file_name); for my $subtree ($tree->look_down(_tag => ...


2

You can read content out of html downloaded via curl, using a mixture of the regular UNIX commands (so grep, awk, etc.) Exactly how depends on exactly what the form looks like and how you want to interpret it. You can also do it with perl and other languages which have libraries which make it easier. However, input forms only have content in the fields ...


2

Simple answer is: do not use shell to parse XML. Use a XML parser instead, e.g. one of the numerous for Perl: XML::Parser, XML::Simple, or any other language. For HTML, HTML::Parser is an option (if we stay with Perl). If you want to use bash, you can play with the read built-in and a loop a bit.


1

If ruby is available you can do the following ruby -e 'puts readlines.join[/(?<=<tr>).+(?=<\/tr>)/m].gsub(/<\/?tr>/, "")' file where file is your input html file. The command executes a Ruby one-liner. First, it reads all lines from file and joins them to a string, readlines.join. Then, from the string it selects anything between (but ...


1

if you only want ... of all <tr>...</tr> do: grep -o '<tr>.*</tr>' HTMLFILE | sed 's/\(<tr>\|<\/tr>\)//g' > NEWFILE for multiline do: cat HTMLFILE | tr "\n" "|" | grep -o '<tr>.*</tr>' | sed 's/\(<tr>\|<\/tr>\)//g' | sed 's/|/\n/g' > NEWFILE check the HTMLFILE first of the char "|" (not ...


1

shbot is a very nice IRC bot used for the #bash Freenode channel. You can ask it to run Bash code for you: /privmsg shbot echo test It should be relatively easy to adapt this to work with a static web page.


1

You can use grep. To include the double quotes: grep -o '"http://[^"]*"' myfile.html To exclude the double quotes: grep -o 'http://[^"]*' myfile.html Edit You may want to do some further filtering to ensure that you only match the URLs in the JavaScript objects: grep -o 'mp3: "http://[^"]*"' myfile.html | grep -o '"http://[^"]*"' grep -o 'mp3: ...


1

Mutt does not parse HTML. If you turn off HTML viewing, you won't see HTML content. Many mailers generate MIME multipart messages, with the same text present twice: once as an HTML part (text/html), and once as a text part (text/plain). The text part is mostly or completely devoid of formatting; some mail programs generate ASCII representations of emphasis ...


1

Don't be too sure if something is not working. Remember that you can't filter that is passed through a HTTPS connection. HTTPS means that the connection is secured, so privoxy only sees encrypted data pass and lets it pass unfiltered. @rozcietrzewiacz: Yeah, may be that might be constraining, but that's your opinion. I find it much more concerning that ...


1

Most unix tools, like split, are file format agnostic. To split files that use a specific format (like HTML) into smaller validly formatted files, use specific tools. For HTML splitting, htmldoc is the first I found looking quickly on the web. It has been packaged (at least in debian, ubuntu, fedora, gentoo, etc…). Do not use sed-ish tricks that make ...


1

You could first extract and remove the header/footer of the source file, split it and add the extracted header/footer to each split. You could use xpath or sed to do the editing of the source file. For example this command line strips the header footer of a file: $ sed -e '0,/<body>/d' -e '/<\/body>/,$d input.html Where sed is the GNU one ...


1

andcoz's answer provided me with a good search term, i.e. just using $ apt-cache search gallery results in some packages matching the above criteria, e.g. bins igal2 - Nice looking film reel effect in gallery by default, scaling of original images is not the default (see --bigy), homepage and man page are missing some usage examples jigl lazygal - ...


1

You can hack a solution together with Dropbox. Install Dropbox CLI. Then copy files to a public gallery which presents the images in a minimally styled format. Optionally, you could use this bash upload script. DropboxCLI has an option to copy the gallery URL copygallery - Copies the gallery url to the clipboard so that you can then share that ...


1

Have you considered Watir? http://watir.com/ When you've added the package, you can run it as a standalone file or from irb, line-by-line after include 'watir-webdriver'. I've found it to be more responsive than selenium-webdriver, but without the test recording GUI to help work out complex test conditions.


1

I just recently started using the WebDriver from Selenium 2 in Java. There is a driver called HtmlUnitDriver that fully supports JavaScript but does not fire up an actual browser. It is not a light solution but it does get the job done. I've designed the code to run from the command line and save the web data to files.



Only top voted, non community-wiki answers of a minimum length are eligible