Tag Info

Hot answers tagged

25

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 ...


15

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"; ...


6

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 ...


5

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 ...


5

With a recent version of xclip (the -t option was added in 2010 but not released yet AFAICT, so you'd need to get it from subversion, or use the one packaged in Debian). xclip -o -selection clipboard -t text/html | pandoc -r html -w markdown And if you want to make that back into the clipboard: xclip -o -selection clipboard -t text/html | pandoc -r ...


5

Try: wget -r -np -k -p http://www.site.com/dir/page.html The args (see man wget) are: r Recurse into links, retrieving those pages too (this has a default max depth of 5, can be set with -l). np Never enter a parent directory (i.e., don't follow a "home" link and mirror the whole site; this will prevent going above ccc in your example). k Convert links ...


5

This will do the trick: echo "<table>" ; print_header=true while read INPUT ; do if $print_header;then echo "<tr><th>$INPUT" | sed -e 's/:[^,]*\(,\|$\)/<\/th><th>/g' print_header=false fi echo "<tr><td>${INPUT//,/</td><td>}</td></tr>" ; done < Medical.csv ; echo ...


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

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 => ...


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

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 ...


4

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.


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' ...


4

Pressing this button will only cause the browser to submit a POST request to the server, together with all the values of the according form as payload in the body of the request. So if you want the effect of this click reproduced in a shell script, what you have to do is to build your data in the format it's passed in a POST request, and then submit a POST ...


4

As the HTTP spec (and the error message from your HTTP server) specify, you need one blank line between the HTTP headers and the body, otherwise the server doesn't know where the headers end and the body begins. From RFC 2616 (emphasis my own): Request (section 5) and Response (section 6) messages use the generic message format of RFC 822 [9] for ...


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

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

As it turns out, the link in the question hinted at a working solution in the form of xclip: pandoc -S file.mkd | xclip -t text/html ...and then I can paste it straight into the document in libreoffice, properly formatted. This works with the versions of the programs in the Ubuntu 13.04 repositories (pandoc 1.10.1 and xclip 0.12) -- the -t option for ...


3

One option here is glade: Glade is a RAD tool to enable quick & easy development of user interfaces for the GTK+ toolkit and the GNOME desktop environment. The user interfaces designed in Glade are saved as XML, and by using the GtkBuilder GTK+ object these can be loaded by applications dynamically as needed. By using GtkBuilder, ...


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

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.


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.


2

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 ...


2

The web server doesn't typically translate ~ravbholua to your user home directory (it would take special configuration to make it do so), nor would I recommend attempting any method to get it to do so as that makes the entire contents of the home directory visible through the server - a major security risk. Try creating a public_html directory under the ...


2

Since you mention Synaptic: Debian puts all documentation under /usr/share/doc/PACKAGE, except for man pages and info manuals. Furthermore Debian provides two packages to browse and search documentation in an amalgamated way through a web browser: dhelp (which doesn't need a local web server, but only shows HTML documentation) and dwww (which requires a ...


2

If the file were correct xml, you could use an xml parsing tool. Otherwise, if there were no other (nested) div section inside that section, you could have done: pcregrep -Mo '(?s)<div[^>]*id="id1".*?</div>' the-file.html Here, you could try something like: awk -vRS='<' ' inside || /^div[^>]*id="id1"/ { inside = 1 if (/^div/) ...


2

In general, one should use a tool that understands html. For limited purposes, though, a simple command may suffice. In this case, sed is sufficient to do what you ask and works well in bash scripts. If you have captured the source html into index.html, then: $ sed -n 's/.*<p><p tabindex="0">\([^<]*\).*/\1/p' index.html Clementine is a ...



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