2

I have a script that runs commands & takes a screen shot. I want the man file to display & grab a screen shot of it. My script works for the commands alone but if I add "man " before the command it just gives an error "man command not found"

try(){
   clear
   timeout 0.2 $1 
   re=$?
   echo trying $1>>log.txt
   echo result is $re>>log.txt
   if [ ! $re -eq 127 ]; then
       sleep 0.2
       import -window osboxes@osboxes:~/Downloads/Parser\ Project\Code/iteration\ 3 iter3/$1.png
       echo $1 captured>>log.txt
   fi
}
try man\ AB
try man\ ABRT\-ACTION\-ANALYZ
try man\ ABRT\-ACTION\-ANALYZ
try man\ ABRT\-ACTION\-ANALYZ

...etc

The list of commands is quite long but they all exist on the system.

Also if I just have:

try ABRT-ACTION-ANALYZ or try AB for example then it finds the commands & works but of course not showing the man file.

Please don't ask my why I don't look at the man files some other way - I am asking how to get this script to work.

Is it possibly a man path issue?

4
  • This "man" is a file with spaces or you mean command man which displays manual for some command?
    – jimmij
    Jan 4, 2016 at 23:42
  • 1
    Try getting rid of the \ (backslash-space) after man and then in the try function using a $2 such as timeout 0.2 $1 $2 Jan 4, 2016 at 23:48
  • yes its the man command that shows the help Jan 5, 2016 at 0:55
  • Did you check shell path, and your man path?
    – CJ Dana
    Sep 18, 2016 at 2:06

2 Answers 2

1

The problem could be due to the way the man command displays information on the screen. You can likely get around this by dumping the man page to the screen with:

man -P cat <command name>

IE

try man\ \-P\ cat\ ABRT\-ACTION\-ANALYZ
3
  • Awesome thats done it - thanks. Prob is now its not saving the screen shots. I am using imagemagick to capture the shell window. Jan 5, 2016 at 1:00
  • I am using imagemagick to capture the shell window. Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275 Jan 5, 2016 at 1:12
  • The script is generated by a Java app that determines what man files are on the system - it is in that app that the imagemagick is set up. Jan 5, 2016 at 1:14
0
     try(){
  clear
timeout 0.2 man -P cat $1 
re=$?
echo trying $1>>log.txt
echo result is $re>>log.txt
if [ ! $re -eq 127 ]; then
    sleep 0.2
    import -window osboxes@osboxes:~/Downloads/Parser\  Project\Code/iteration\ 3 iter3/$1.png
    echo $1 captured>>log.txt
fi

}

1
  • This works - no need for man before the command list Jan 7, 2016 at 0:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .