Find the answer to your Linux question:
Results 1 to 8 of 8
I suddenly get an idea to export man manual in linux to txt format, so that I can read it anywhere especially in my iPhone or my tablet. I have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2013
    Location
    The city of Beijing
    Posts
    12

    How to export man manual to txt format?


    I suddenly get an idea to export man manual in linux to txt format, so that I can read it anywhere especially in my iPhone or my tablet.
    I have tried the command below(here take the utility "less" for example) but it does not seems good.
    man less > less.manual.txt
    What is the better way?

  2. #2
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,134
    The way you have done it is exactly what I would have recommended.

  3. #3
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    Same here. I would probably do the same for all of the most common commands that are typically used.
    Depending on your phones data plan, you could also check out this online man page: Linux man pages
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  4. #4
    Just Joined!
    Join Date
    May 2013
    Location
    The city of Beijing
    Posts
    12
    Quote Originally Posted by rcgreen View Post
    The way you have done it is exactly what I would have recommended.
    Thank you for replying. But in this way, the result file will contain many unrecognizable characters and the file is hard to read. Very obviously the unrecognizable characters come from the original font decorate in man manual.

  5. #5
    Just Joined!
    Join Date
    May 2013
    Location
    The city of Beijing
    Posts
    12
    Quote Originally Posted by jayd512 View Post
    Same here. I would probably do the same for all of the most common commands that are typically used.
    Depending on your phones data plan, you could also check out this online man page: [I am only allowed to post URLs to other sites after I have made 15 posts or more.]Linux man pages
    Thank you for replying. I will check it out.

  6. #6
    Just Joined!
    Join Date
    May 2013
    Location
    The city of Beijing
    Posts
    12
    In recent days, I can acess a cent-os in my own PC at home and a ubuntu in a school PC that can not contact the internet. I discovered that in both distro, man can be exported out as a post script format. But to the direct ">" approach, in ubuntu it is OK, but in cent-os there will be many unrecognizable characters.
    The need that I want some references of man to read rather than the consol is filled by linux.die.net/man. I post these just for interests.

  7. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by cmpltrtok View Post
    The need that I want some references of man to read rather than the consol is filled by linux.die.net/man. I post these just for interests.
    a while back i wrote a small Perl CGI script that would allow you to enter a command name in a form whose man page you wanted to read, and it would display that man page (if found on the system) in the web browser, kind of like how linx.die.net/man works, but local (no internet connection required). it requires the "man" program, and "man2html", which should have come with "man". If you have a webserver set up on your Linux box, give it a whirl.

    call it "man.pl", stick it in your webserver's CGI dir, and make it executable. then load it in a browser, e.g.:

    Code:
    http://localhost/cgi-bin/man.pl
    here's the code:
    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    use CGI::Carp qw(fatalsToBrowser);
    use CGI;
    use File::Copy;
    use File::Basename;
    
    $| = 1;
    
    # parse query string 
    my $cgi = new CGI;
    my %qs;
    $qs{$_} = $cgi->param($_) for($cgi->param());
    
    my $body;
    my $title;
    
    unlink('/tmp/man.tmp.gz') if(-f '/tmp/man.tmp.gz');
    unlink('/tmp/man.tmp') if(-f '/tmp/man.tmp');
    
    if($qs{'man'}){
      my $manpage = $qs{'man'};
      $title = "Man Page for $manpage";
      $body .= "man page: <b>$manpage</b><BR>\n";
      chomp(my $manfile = `man -w $manpage`);
      if($manfile){
        $body .= "man page: '$manpage'<BR>".
                 "man file: '$manfile'<BR>\n";
        if($manfile =~ /\.gz$/){
          $body .= "Making copy of manpage...\n";
          if(copy($manfile,'/tmp/man.tmp.gz')){
            $body .= "OK<BR>\n";
            $body .= "Uncompressing manpage...";
            if(system("gunzip /tmp/man.tmp.gz") != '0'){
              $body .= "FAILED<BR>\n";
            }else{
              $body .= "OK<BR>\n";
              $body = '';
              my $cmd = join(' ','man2html','/tmp/man.tmp');
              open(PH,"$cmd |") or die "can't run '$cmd': $!\n";
              while(<PH>){
                chomp;
                next if(/^content-type/i);
                $body .= "$_\n";
              }
              close(PH);
              unlink('/tmp/man.tmp');
            }
          }else{
            $body .= "FAILED<BR>\n";
          }
    
        }else{
          $body .= "ERROR: Don't know how to deal with non-gz manpage";
        }
      }else{
        $body .= "ERROR: Could not find file for man page <b>$manpage</b><BR>\n";
      }
    }else{
      $title = 'Man Pages';
      $body .= "
    <form action='?' method='get'>
    <input type='text' name='man'></input>
    <input type='submit' value='GO'></input>
    </form>
    ";
    }
    
    print <<"EOF";
    Content-type: text/html
    Cache-control: no-cache/no-store
    
    <html>
    <head>
    <title>$title</title>
    </head>
    <body>
    $body
    </body>
    </html>
    EOF
    exit(0);

  8. #8
    Just Joined!
    Join Date
    May 2013
    Location
    The city of Beijing
    Posts
    12
    Quote Originally Posted by atreyu
    a while back i wrote a small Perl CGI script that would allow you to enter a command name in a form whose man page you wanted to read
    You are so kind, atreyu. Thanks a lot! I will try it out later.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •