[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Mounting an AppleShare volume using MacPerl?



Peter,

At 20:09 Uhr -0500 23.06.1998, Peter Scherbring wrote:
>Does anyone know if you can mount an AppleShare volume using MacPerl? The
>volume needs to be accessible on the desktop like any volume you mount
>using the Chooser. I have looked through the reasonable pods in the
>standard MacPerl distribution as well as on-line and in the new MacPerl
>book with no luck. Also, the Chooser does not seem to like AppleScript so
>that is not an option. Did I overlook something?
>
>Thanks
>Peter Scherbring
>
>MacPerl 5.2.0r4
>MacOS 8.1

(Besides The Book) I recommend a look at
http://www.binary.net/dturley/macperl/search.html. Lots of interesting
stuff there.

>From an old post from Chris:

>Requires the Mount Volume OSAX (Laurent has it if you can't find it online).
>
>
>#!perl -wl
>use strict;
>use Mac::AppleEvents;
>
>mount('PowerPudge','PowerPudge','Pudge','passwd');
>sub mount {
>    my($evt,@evt,%evt,$be,$rp,$er);
>    die 'usage: mount(VOLUME,SERVER,USER,PASSWORD,ZONE)' if (!$_[0] ||
>!$_[1]);
>    %evt = (
>        VOLM=>shift,    #required
>        SRVR=>shift,    #required
>        USER=>shift,    #optional
>        PASS=>shift,    #optional
>        ZONE=>shift,    #optional
>    );
>    foreach (keys %evt) {
>        if ($evt{$_}) {
>            $evt .= ",$_:TEXT(@)";
>            push @evt,$evt{$_};
>        }
>    }
>    substr($evt,0,1) = '';
>
>    $be =
>AEBuildAppleEvent('aevt','mvol',typeApplSignature,'MACS',0,0,$evt,@evt) ||
>die $^E;
>    $rp = AESend($be, kAEWaitReply) or die $^E;
>    if (defined($er = AEGetParamDesc($rp,'errn'))) {
>        warn 'Mount Volume error ', AEPrint($er);
>    }
>}
>
>__END__

And from "Whitney Cunha" <whitney_cunha@sequana.com>:


>How about just using Applescript rather than buildling the apple event?  I
>don't know enough Perl to quite understand yours, but I do see that you handle
>errors better than this - I haven't figured out how to get the errors back
>from DoAppleScript yet.  Thank you for your example.  I can see that will be
>handy.
>
>Here's the unmount you wanted in Applescript (uses a Finder event) - the mount
>came mostly from an old MacPerl digest.
>
>#!/usr/local/bin/perl -w
>
>use Carp;
>
>&mount_volume ("Volume", "Server", "Genotyping", "username", "password") or
>         croak "There is no such volume or I can't mount it!\n";
>
>&unmount_volume ("Volume");
>&MacPerl'Quit(1);
>
>
>#**************************************************************************
># Mounting & unmounting servers subroutines
>#**************************************************************************
>sub mount_volume {
>   local   ($volume, $server, $zone, $username, $password);
>
>    ($volume, $server, $zone, $username, $password) = @_;
>    unless (&MacPerl::DoAppleScript(<<_EOAS_)) {
>      tell application "Finder"
>        if not exists disk \"$volume\" then #194#
>          MountVolume Volume \"$volume\" Server \"$server\" Zone \"$zone\"
>#194#
>Username \"$username\" Password \"$password\"
>      end tell
>_EOAS_
>    }
>           return 1;
>}
>
>sub unmount_volume {
>     local  $volume;
>
>     my ($volume) = $_[0];
>
>     unless (&MacPerl::DoAppleScript(<<_EOAS_)) {
>          tell application "Finder"
>               if (list disks) contains \"$volume\" then
>                    put away disk \"$volume\"
>               end if
>          end tell
>_EOAS_
>     }
>}
>

Peter


Peter Hartmann
Visiting Scholar
Ritsumeikan University, Kyoto, Japan
e-mail:
hartmann@mbox.kyoto-inet.or.jp (preferred)
phv00542@askic.kic.ritsumei.ac.jp




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch