First off, you need to know where the user lives, ask the system with getpwnam and friends. Then try to mount the home dir. It's up to your system's /etc/fstab (and by fstab, nsswitch as you may use NIS+ or something)

use User::pwent; my $username = 'f00li5h'; my $user = getpwnam($username); printf "%s aka (%s) lives in %s $/", $user->name, $user->gecos, $user->dir; #f00li5h aka (f00li5h and5illy) lives in /home/f00li5h use File::Spec; my @paths = File::Spec->splitdir( $user->dir ); # start at the most specific directory (/home/f00li5h) head # to the lest specific (/) while( @paths ){ # get the system to mount (rather than just print) printf "mount %s $/", File::Spec->catdir( @paths ); last if -d $user->dir; # stop looking when the dir turns up pop @paths ; }

This has massive massive YMMV attached to it and I'm sure there's a better way than blindly mounting things until the homedir appears, particularly if the user's homedir is with a symlink of some sort.

/home/f00li5h -> /media/homes/big/f00li5h
@_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

In reply to Re: Check if home dir is mounted? by f00li5h
in thread Check if home dir is mounted? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.