PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Karl Holz  >  Automator Shell Action Tools  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Class source
Class: Automator Shell Action Tools
Process console input and environment variables
Author: By
Last change: fix again

php classes doesn’t render README.md files as expected
Date: 5 years ago
Size: 3,315 bytes
 

Contents

Class file image Download

Shell Action Tools

In my research into building Automator Actions with Shell Scripts (such as bash/sh/ksh), I notices that hasn't been much written about the subject. So I have based my work on these urls:

This is a small effort to show that PHP can be used in more places than just Websites; this class is aimed a processing command input and enviroment variables passes to the script from the prevous Automator Action. Much like a pipe ( | ) when using the command line

This class will process the variables set and passed before the command (set as values in the enviroment variable $_ENV) and the document sent to standard input ({command} < STDIN).

Using the Code in main.command

> \#!/usr/bin/php > > <?php > > require 'ShellActionTools.class.php'; > > $s=new ShellActionTools(); > > echo "arg is: " . $s->arg . "\n"; > echo "arg2 is " . $s->arg2 . "\n"; > > exit();

Debuging Class on console

> $ arg="one" arg2="two" php main.command < config-file

or like this

> $ ls | arg="one" arg2="two" php main.command

As you can see with the example above, you can use this class to help you process to types of input for a shell tool; but the main focus is building an Mac OS X Automator.app Action in XCode using shell scripting -- PHP in this case. Use the debug.main.command.sh script to see the basics of this class in Action.

Ignored ENV keys

  • LDFLAGS
  • CPPFLAGS
  • TMPDIR
  • LANG
  • PKG_CONFIG_PATH
  • TERM_PROGRAM
  • TERM
  • SHELL
  • TERM_PROGRAM_VERSION
  • TERM_SESSION_ID
  • USER
  • SSH_AUTH_SOCK
  • LOGNAME
  • SECURITYSESSIONID
  • DBUS_LAUNCHD_SESSION_BUS_SOCKET
  • XPC_FLAGS
  • XPC_SERVICE_NAME
  • HOME
  • PATH
  • PWD
  • OLDPWD
  • PYTHONPATH
  • SHLVL
  • _
  • __CF_USER_TEXT_ENCODING
  • Apple_PubSub_Socket_Render

These were removed so that it would be easyer to process the enviroment variables passed or set on the command line

XCode Interface

The XCode interface builder isn't that hard to use once you become fimilar with the tools and the items you can add to the interface. The links above will give you a short guide on how to build an automator shell script action; the pages are dated, showing screen shots from Mac OS X 10.6 or 10.5.

I created my VLC-Cutter action with Mac OS X 10.11.3

Please take a look at macosxautomation.com for more ideas on what you can do with Automator workflows.

\*NIX Users, turn that frown upside down

If you take a look at the Debugging Class on the console section, you'll notice that this class can be used in normal Linux/Unix shell scripts with PHP using the same format; I'm not going to leave you linux heads empty handed, apple isn't the only fruit computer I use ;) ... Raspbery Pi's could also benifit from our PHP skills!

This class will only be focussed on dealing with the piped input and enviroment variables. I'm most likely going to build something that will deal with getops related stuff later on, maybe an extention of this class.

For more information send a message to info at phpclasses dot org.