Tag Info

Hot answers tagged

36

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


16

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


8

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; luakit '%s' &; test=test -n "$DISPLAY"; needsterminal; ...


8

Even if you fix the errors in your shell syntax as Braiam's answer correctly identifies, you will never get this to really work right. At best you might find a few mistakes of the sort you know you make; but you will never get grep to reliably find broken tags of the sort you might not have already noticed you are breaking. To do this right you need to use ...


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


6

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

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

That's OS/distribution/desktop-environment dependent, but in many places, you'll find a xdg-open command that does just that.


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

Why use awk? sed is better at this: sed -ne 's/.*\(http[^"]*\).*/\1/p' < foo.js


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

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

You will have to add Content-Type header to your email to make this happen. echo "<html><b>Hello</b></html>" | mail -a "Content-type: text/html;" -s "Testing" me@example.com will work


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

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

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

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

Keeping in mind that HTML is not a regular language, you could probably at least narrow it down with: grep -Ro '[a-zA-Z0-9]+\.[a-zA-Z0-9]{1,4}' *


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


4

Your problem(s) are in this line: if `cat $htmlFile | grep -inE "\<br\>"` ; then It's telling the shell to: cat a file, parse it and look for lines that match the <br> tag, execute the output The problem is the last step, you shouldn't execute the output of the command but test it: if grep -inEq "\<br\>" $htmlFile ; then Of ...


4

The best strategy would be to use a proper html parser that can spit out the value of all <a> tags. Here, xmlstarlet is specifically an XML parser, and your HTML may not be well-formed XML, but you might get the idea: echo '<html> <a href="000000.jpg" title="image name.jpg" target="_blank">Image name.jpg</a> </html>' | ...


3

#!/bin/sh ( echo "To: me@example.com" echo "Subject: hello" echo "Content-Type: text/html" echo echo "<html><b><font size='7'>H</font>ello</b></html>" echo ) | /usr/sbin/sendmail -t


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

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

sed and awk are not well suited for this task, you should rather use a proper html parser. For example hxselect from w3.org: <htmlfile hxselect -s '\n' -c 'tr'


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



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