3

Can somebody suggest me, how to collect output of man command in tcl?

I am writing :-

set hello [ man {command-name}]

and when am executing the script, the program gets halted and man commands start running in the foreground, prompting the user to "press RETURN" again and again till it gets completed.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
crazy_prog
  • 1,085
  • 5
  • 19
  • 34

1 Answers1

4

You're just missing the exec command

set output [exec man cmd-name]

When you do set out [man cmd-name] in an interactive tcl session, the unknown command will intercept the 'man' command and implicitly perform an exec on it. In that scenario, 'man' somehow knows you're interactive and pipes the manpage through your $PAGER.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
  • Thanks glenn. But i am using my own compiler and there are some commands which are known only to it. "exec" will redirect the man command to use shell and it is resulting to "No manual entry for {command-name}", which i don't want. Any suggestions? – crazy_prog May 19 '11 at 18:22
  • @amitesh, what do you mean "using my own compiler"? Can you determine which man pages you need to treat specially? Would it be as simple as modifying the MANPATH env variable to access your special man pages? – glenn jackman May 19 '11 at 18:55
  • @amitesh: `exec` does not “redirect the man command to use shell”. If you want `man` to process a particular file instead of looking it up in the MANPATH, pass in the full name of the file; `file normalize` might be interesting for getting the full filename. – Donal Fellows May 20 '11 at 08:32
  • By "own compiler" means its a product specific compiler which have some more commands. Now,i am not using the MAN command. I am parsing the command specific man file from its base location. After that, i am using cat to collect the file text and using regexp to get the required text. Thanks for Help glenn. – crazy_prog May 25 '11 at 07:23
  • @Donal: I mean, if i execute the mentioned script, then the shell prompt me to press enter rather than collecting the text. When i press enter, it comes out of the script execution and redirected to shell for next command. Thanks Donal. – crazy_prog May 25 '11 at 07:43