| |||||||||||
| |||||||||||
Running operating system commands in Perl
Perl is excellent "glueware" - a language which can be well used to connect together a whole lot of elements. And one of those elements may be operating system commands run from within the Perl program.
Here are (three!) ways that you can do it - in each case leaving the result of running the commands in a scalar variable. # CAUTION - OS Dependent!So that's * A text string of commands in backquotes * A text string of commands in a 'qx' string * A text block (here document) And here's how it runs: BirthdayBoy:csr1 grahamellis$ perl bqYou can also run operating system commands via a piped file handle, where you'll read back the response line by line: open (FH,"ls -l *.*|");Which gives us ... BirthdayBoy:csr1 grahamellis$ perl lbl(By the way - the name of my computer today - "BirthdayBoy" - has been allocated to me by the router at the hotel and does not imply anything about the day I was born!) (written 2008-07-08 18:37:03) Associated topics are indexed under P214 - Perl - System DependenciesP258 - Perl - Solaris, OSX and Linux
Some other Articles
The Story of Well House ManorEnvironment variables in Perl / use Env Finding operating system settings in Perl Perl ... adding to a list - end, middle, start Running operating system commands in Perl Training Course and Business Conference Technology FTP server on Fedora Linux If you are learning Lua, here are some more examples Dealing with The Press Sorting in lua - specifying your own sort routine 1705 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||