Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.comp.lang.applescript > #39
| From | Jolly Roger <jollyroger@pobox.com> |
|---|---|
| Newsgroups | alt.comp.lang.applescript |
| Subject | Re: Print Terminal Output to A PDF file |
| Date | 2017-09-21 15:52 +0000 |
| Organization | People for the Ethical Treatment of Pirates |
| Message-ID | <f2i5h0F9avrU1@mid.individual.net> (permalink) |
| References | <004e6c0c-bfda-4316-8efa-3d44c7c617ec@googlegroups.com> |
On 2017-09-21, Matthew W <matthewwisan@gmail.com> wrote: > Hey I created an applescript that outputs info to the terminal window, > and now I'm trying to find if there is a way to automatically take the > information that is output to Terminal and save that info as a PDF > file? > > I'm somewhat new to AppleScripting (and haven't use the terminal much > since college), so I'm trying to figure out if this can be done > easily? > > Thanks for any help Why bother scripting the Terminal application directly if all you want to do is run a command-line program, which you can do directly in AppleScript? Why bother with a PDF if the output of any command-line program is just plain text? You can use the "do shell script" command to run any command-line programs you want and send the output to a plain text file. For instance, here's a simple script that runs the "top" command and puts the output of it into a plain text file on the desktop: -- begin script property outputFilename : "top_output.txt" property outputFile : (the POSIX path of the (path to the desktop) & outputFilename) as text property topCommand : "top -u -l 2 -n 21 -ncols 17 > " & the quoted form of outputFile set commandOutput to do shell script topCommand -- end script As you can see there are three properties at the top of the script: * outputFilename: the name of the text file containing the output * outputFile: the full path of the output text file * topCommand: the command-line program to run Notice that the topCommand uses the > command-line syntax followed by the path to the output file, which causes the output of the "top" command to be placed into a new text file at that path. The "do shell script" line at the end actually executes the command, which in turn sends the command output to the text file on the desktop. -- E-mail sent to this address may be devoured by my ravenous SPAM filter. I often ignore posts from Google. Use a real news client instead. JR
Back to alt.comp.lang.applescript | Previous | Next — Previous in thread | Next in thread | Find similar
Print Terminal Output to A PDF file Matthew W <matthewwisan@gmail.com> - 2017-09-20 23:44 -0700 Re: Print Terminal Output to A PDF file Jolly Roger <jollyroger@pobox.com> - 2017-09-21 15:52 +0000 Re: Print Terminal Output to A PDF file josephb@nowhere.invalid (Joseph-B) - 2017-09-21 18:11 +0200
csiph-web