Easiest way to pass an .iso to a command line tool on OSX?

Come up with a useful post-processing script? Share it here!
Post Reply
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Easiest way to pass an .iso to a command line tool on OSX?

Post by roads »

Hi, I would like to pass an iso on the MAC to an extraction program.
Maybe it would be nice  if some script wizard would make a general little mac script that would allow people to just replace the program and play around with the parameters.

can someone help please?

would this be enough to be saved in an .rtf file in the script folder set in the config? Does .iso after the filename $3 only take the iso file or files?

Code: Select all

dirname=$1
filename=$3
/Applications/extract-xiso -x "$1/$3.iso"

if the usage is as follows:

Code: Select all

Usage:

    /Applications/extract-xiso [options] [-[lrx]] <file1.xiso> [file2.xiso] ...
    /Applications/extract-xiso [options] -c <dir> [name] [-c <dir> [name]] ...

  Mutually exclusive modes:

    -c <dir> [name]     Create xiso from file(s) starting in (local or remote)
                          <dir>.  If the [name] parameter is specified, the
                          xiso will be created with the (path and) name given,
                          otherwise the xiso will be created in the current
                          directory with the name <dir>.iso.  The -c option
                          may be specified multiple times to create multiple
                          xiso images.
    -l                  List files in xiso(s).
    -r                  Rewrite xiso(s) as optimized xiso(s).
    -x                  Extract xiso(s) (the default mode if none is given).
                          If no directory is specified with -d, a directory
                          with the name of the xiso (minus the .iso portion)
                          will be created in the current directory and the
                          xiso will be expanded there.

  Options:

    -d <directory>      In extract mode, expand xiso in <directory>.
                        In rewrite mode, rewrite xiso in <directory>.
                        This option is required when extracting to an ftp
                          server.
    -D                  In rewrite mode, delete old xiso after processing.
    -h                  Print this help text and exit.
    -f <ftp_server>     In create or extract mode, use <ftp_server> instead of
                          the local filesystem.
    -m                  In create or rewrite mode, disable automatic .xbe
                          media enable patching (not recommended).
    -p <password>       Ftp password (defaults to "xbox")
    -q                  Run quiet (suppress all non-error output).
    -Q                  Run silent (suppress all output).
    -u <user name>      Ftp user name (defaults to "xbox")
    -v                  Print version information and exit.
Last edited by roads on February 21st, 2010, 1:20 pm, edited 1 time in total.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by sweetie »

I haven't tested this. (No mac.), but it should do the trick:

You had the right idea btw, though "$3.iso" would assume the ISO filename was that of the dirname.

Code: Select all

#!/bin/bash

cd "$1"

for alliso in *.iso; do
    ##anything after a hash is a comment, and does not effect the script.
    ##you could have subdirs created for each ISO, in the case of multiple ISOs like so.

    #if [ ! -d "${alliso%.*}" ]; then
    #mkdir -p "${alliso%.*}" # "${alliso%.*}" is filename of ISO without extention.
    #mv -f "$alliso"  "${alliso%.*}"
    #cd  "${alliso%.*}"; fi
   
     /Applications/extract-xiso -x "$alliso"

    #cd "$OLDPWD"
done


Also, filename can be anything, though '.sh' is common extention for bash scripts.

Once you've written it up, in terminal run:

chmod -c +x "/path/tofilename.ext"

(This adds the executable bit.)
Last edited by sweetie on February 21st, 2010, 6:51 am, edited 1 time in total.
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by roads »

Thank you but the last command will not work

chmod -c +x "/path/extractiso.sh"

with a captal -C neither


if I bash the plain text file it gives me some errors i cant debug.
Last edited by roads on February 21st, 2010, 9:48 am, edited 1 time in total.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by sweetie »

Oh, you can run without '-c', it just reports back status if successful or failed.


Also, could you post the error it spits out, assuming the above doesn't sort it.


To set the script, stick it in SAB 'scripts' dir. and select it from dropdown in categories section in webUI.

One thing, you could change "$OLDPWD" to ".." , it could be that OSX bash doesn't include that as a global variable.
Last edited by sweetie on February 21st, 2010, 10:44 am, edited 1 time in total.
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by roads »

If I run chmod +x extractiso.sh in the directory of the .sh there is no report at all no error nothing seems to happen. The info of the file stays "plain text" its not executable. SAB simply ignores it after the file is downloaded and processed. I dont recall where the debugging problems came up but it was the first "then" in line 9 as I remember.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by sweetie »

I'm not familiar with OSX at all, but have a look on right click > properties of the script (or whatever the equivalent is.) and try and set executable bit from there. (That's most likely cause of errors.)
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by roads »

Me neither LOL, guess we have to wait for someone fit with the Mac Terminal to make this work. The rightclick menu does not allow me to set it as executable.

imac:scripts pb$ bash extractiso.sh
extract-xiso v2.5 (10.25.05) for macos-x - written by in

open error: *.iso No such file or directory
imac:scripts pb$

bashing it works
Last edited by roads on February 21st, 2010, 11:49 am, edited 1 time in total.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by sweetie »

The shell is case sensitive, are the extensions of the ISOs uppercase?

If so, replace

Code: Select all

for alliso in *.iso; do
with

Code: Select all

for alliso in *.iso *.ISO; do
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by roads »

No not that I knew of. I think i just have to make it executable and it would work fine. I am just too stupid to do. There is no iso in the folder, sorry forgot to say. Google said I have to rename the suffix to command. Lets see..
Last edited by roads on February 21st, 2010, 12:43 pm, edited 1 time in total.
sweetie
Full Member
Full Member
Posts: 117
Joined: May 10th, 2009, 10:47 am

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by sweetie »

You'll need an ISO in folder for it to work (it is, it's the program that reports the error.) The above was intended as a post-processing.

You could add a check;

Code: Select all

for alliso in *.iso *.ISO; do

Code: Select all

for alliso in *.iso *.ISO; do
if [ ! -f "$alliso ]; then echo "No ISO found, exiting."; exit; fi
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by roads »

I think it does if i bash the script on a file that is named iso it tries to work on it and says that it did not find the file and folder, what is correct as SAB did not pass it any folder $1. Have to test it with SAB just cant right now.
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Re: Easiest way to pass an .iso to a command line tool on OSX?

Post by roads »

Hey sweetie, the script works like a charm! Thanks again!
roads
Full Member
Full Member
Posts: 106
Joined: February 16th, 2010, 3:06 pm

Re: Easiest way to pass an .iso to a command line tool on OS

Post by roads »

Hey extractiso does not work any more sinse the last dash updates, where can I find a new version?
Post Reply