Index of /xtras/shell_xtra/mac/d11
Name Last modified Size Description
Parent Directory -
_old/ 2016-12-01 16:35 -
readme.txt 2016-07-22 00:32 3.2K
shell_xtra_v0.7-instance_osx10.6plus.zip 2016-12-01 16:28 1.4M
-- xtra Shell
-- v0.7-instance (c) 2016 Valentin Schmidt
new object me
shell_cmd object me, string command, *lineEnd
shell_cmd_list object me, string command
-- Utilities for path conversion
shell_hfs2posix object me, string
shell_posix2hfs object me, string
***************************************************************
FUNCTION OVERVIEW
***************************************************************
---------------------------------------------------------------
shell_cmd (string cmdStr[, string lineEnd])
---------------------------------------------------------------
Description:
============
Executes a commandline program from the Mac OS X (bash) shell and returns the result (stdout and stderr).
If lineEnd is specfied, all line endings (CR, LF OR CRLF) will be replaced with lineEnd (max 8 bytes).
Example usage:
==============
sx = xtra("Shell").new()
-- list files in current folder
res = sx.shell_cmd("ls -l", RETURN)
-- fetch a page with curl
res = sx.shell_cmd("curl -v http://www.adobe.com/")
-- list files in gzip archive
res = sx.shell_cmd("gunzip -l files.gz", RETURN)
-- fetch a page with curl, clean the result with tidy and return the cleaned html code to director
res = sx.shell_cmd("curl -v http://www.adobe.com/ | tidy -c -q", RETURN)
-- convert html-representation of a text member to XHTML
xml = sx.shell_cmd("echo ""E&str_replace(chr(13)&chr(10),"",member(13).html) "E& "| tidy -c -asxhtml")
-- execute php code with php interpreter
ret = sx.shell_cmd("php -r 'phpinfo()'")
-- execute python code with python interpreter
ret = sx.shell_cmd("python -c 'import sys; print sys.path'", RETURN)
---------------------------------------------------------------
shell_cmd_list (string cmdStr)
---------------------------------------------------------------
Description:
============
Like shell_cmd(), but result is returned as lingo list of lines.
Example usage:
==============
sx = xtra("Shell").new()
res = sx.shell_cmd_list("ls")
---------------------------------------------------------------
shell_hfs2posix (string pathStr)
---------------------------------------------------------------
Description:
============
Converts a HFS style path (e.g. "Macintosh HD:Users:goofy:Desktop") to a POSIX path (e.g."/Users/goofy/Desktop").
Example usage:
==============
sx = xtra("Shell").new()
posixPath = sx.shell_hfs2posix(the moviepath)
---------------------------------------------------------------
shell_posix2hfs (string pathStr)
---------------------------------------------------------------
Description:
============
Converts a POSIX style path (e.g."/Users/goofy/Desktop") to a HFS path (e.g."Macintosh HD:Users:goofy:Desktop").
Example usage:
==============
sx = xtra("Shell").new()
desktop = sx.shell_posix2hfs(sx.shell_cmd("echo $HOME/Desktop", EMPTY))
put desktop
-- "MAC:Users:goofy:Desktop"
***************************************************************
DIFFERENCES TO WINDOWS VERSION
***************************************************************
No shell_setCurrentDir()-function. But you can just add a cd my/path/; in front of your commands to have the
same effect. For example,
sx.shell_cmd("cd $HOME/Desktop;curl -v www.adobe.com 1>adobe.htm")
will save the Adobe homepage to your desktop.