Hello!
I’m trying to make an applescript that can view the “man” pages from Terminal in Preview and I’d like to have a text input box so that a user could input whatever it is they would like to look up in the man pages by typing in “rm” or “chmod”, or whatever they would like to look up.
The shell script is:
man -t rm | open -f -a /Applications/Preview.app
Where “rm” is whatever Terminal command the user puts in…
How would I go about inputting a variable into the middle of the shell script?
Can anyone help me out? Thanks.
See also: MacOSXHints “ Use Preview to view formatted man pages (10.4)
surfwax95, this is what I made earlier today:
property theCommand : ""
repeat while theCommand is ""
display dialog "View man page for this command:" default answer theCommand
set theCommand to text returned of result
end repeat
try
do shell script "/usr/bin/man -t " & quoted form of theCommand & " | open -f -a /Applications/Preview.app"
on error errorMsg number errorNum
display alert "Error " & errorNum message errorMsg buttons "Cancel" default button 1
end try