Page 1 of 1

SOLVED: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T06:35:22-07:00
by gareththomasnz
I have a script that takes screenshots of linux man pages as they show in the console

Code: Select all

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\ \-P\ cat\ AB
try man\ \-P\ cat\ ABRT\-ACTION\-ANALYZ
try man\ \-P\ cat\ ABRT\-ACTION\-ANALYZ
try man\ \-P\ cat\ ABRT\-ACTION\-ANALYZ

My true list of commands is quite long. Without \-P\ cat\ it wont display the man files. In its present form it does display each man file but wont take the screen shot of each.

Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Any idea how I should correct it - I have no clue.

Re: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T11:33:18-07:00
by snibgo
Your $1 will contain spaces. I expect they are passed to the command line, so your import command ends with:

Code: Select all

iter3/man -P cat AB.png
If this should be a filename, you should probably quote it.

Re: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T15:41:55-07:00
by gareththomasnz
Sorry can you elaborate more clearly?

The files have to be given the name of the command that is being run. Over 1000 of them. If I run it without man - just the raw command it saves & names the files OK.

But I need to take a screen shot of the man file output for each command & give it a relevant name. Not manually of course. I'm not familiar at all with shell scripting to make it difficult.

Re: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T15:50:19-07:00
by snibgo
I'm not a bash expert. If you include "-debug all" in the convert command, IM will tell you the arguments it sees.

Re: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T15:55:10-07:00
by gareththomasnz
Debug just gives that error about -P

Re: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T16:06:47-07:00
by snibgo
The top of the debug output will have something like this:

Code: Select all

 Command line: c:\im\ImageMagick-6.9.2-5-Q16\convert {-debug} {all} {rose:} {r.png}

Re: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T16:15:53-07:00
by gareththomasnz
Working now:

Code: Select all

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
}
try AB
try ABRT\-ACTION\-ANALYZ
try ABRT\-ACTION\-ANALYZ
try ABRT\-ACTION\-ANALYZ

Re: Error: unrecognised option '-P' error/import.c/ImportImageCommand/1275

Posted: 2016-01-06T16:17:46-07:00
by gareththomasnz
So the man command was inserted after the timeout not in the list of commands - not in the import either