On Mar 29, 2004, at 16:17, Chris Devers wrote:


On Mon, 29 Mar 2004, Joseph Alotta wrote:

On Mon, 29 Mar 2004, <???> wrote:

Yes - I think you're kind of right, so, if you have the command line
as such: system "open *.pdf";

This would expand to match everything such as:  system "open a.pdf
b.pdf c.pdf d.pdf";
Each of the items are treated in an Unix shell as separate arguments.

Now, for (heh heh) arguments sake, if we executed the same command as
such:

system 'open a.pdf b.df c.df d.pdf';

This would treat the list passed as ONE argument.

This statement would fail:  system 'open *.pdf'; since expansion of
the wildcard character would not take effect (due to the syntax).

The key is to write a little shell program which would collect all
*.pdf into a list of one argument passed to the "system open" command.


Now go fish! (parable, sorry!) ;-)

I tried your advice and it still doesn't work. It still opens each file in a separate window.



  [Abba:~/oldperlcode] josephal% ./test
  [Abba:~/oldperlcode] josephal% cat ./test
  #!/usr/bin/perl

  system "open /Users/josephalotta/Desktop/Picture1.pdf
  /Users/josephalotta/Desktop/Picture2.pdf";

[Abba:~/oldperlcode] josephal%


That isn't quite what was being suggested though -- you double-quoted it.
I'm not sure if that matters, but it isn't what was suggested.

Yes Chris, in standard Unix shells there IS a difference 'tiwxt single and double quotes, but,
I've come across sometimes strange differences 'twixt, csh, tcsh, bash, sh, and taco-shell. (sorry,
bad pun).


But I just tried this under Darwin, and, hmm, it seems to operate the same, regardless....

I still would try to do something such as (rough script here)

open <COMMAND> "ls *.files |"; # Don't forget to code a die here if unsuccessful in opening. Defensive programming!
while <COMMAND> {
$theParms .= $_; # you may or may not need to cho(m)p !
}
$theCommand = "system open '" . $theParms . "'";


system (or eval) ($theCommand); # and check for RC...

Something like that, as above in Perlese, I think, should do the trick!
If files are not found, you'll need to, mayhap,
prepend the results of: $home_dir = `pwd`; (Nota Bene! I'm using the backtick ` instead of the single quote ' for this!).



BPR






In any case, the example being given here would work just fine when pulled
out of the shell script & run from the command line. Consider:


    $ ls h*pdf
    hosts_alia.pdf  hosts_canon.pdf
    $ open hosts_alia.pdf hosts_canon.pdf  # documents open separately
    $ open "hosts_alia.pdf hosts_canon.pdf"
    2004-03-29 16:10:28.558 open[8355] No such file:
    /homes/file4/cdevers/docs/hosts_alia.pdf hosts_canon.pdf
    $ open 'hosts_alia.pdf hosts_canon.pdf'
    2004-03-29 16:10:34.446 open[8356] No such file:
    /homes/file4/cdevers/docs/hosts_alia.pdf hosts_canon.pdf

The example here depends on the behavior of /usr/bin/open, and any
problems in that program will be manifest whether you're invoking it
directly from the command line or indirectly through a Perl script.
Therefore, the Perl version is just adding complexity here and is giving
you another thing to debug -- it would be better to test this another way.


Because /usr/bin/open appears to be broken, and because it has behaved
this way for a while now, AppleScript seems more promising as a way to
open multiple documents as a set...


-- Chris Devers





- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please take the time to preview my forthcoming book of essays!
http://www.ZeusonaCork.com
Join the blog too! Thank you!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -




Reply via email to