samba-mounted directory, OS X, bash, 'system' calls

Discussion in 'Perl Misc' started by John, Sep 9, 2009.

  1. John

    John Guest

    Have got a Perl script called from within a bash script.
    Bash connects to a Samba share:

    umount ~/Documents/bin/pdfs
    mount -t smbfs //NAME:pass@server/SHARE ~/Documents/bin/pdfs

    Then it calls this Perl script:

    #!/usr/bin/perl -w
    my $sourcedir="~/Documents/bin/pdfs";
    print "sourcedir=$sourcedir\n";
    system("ls",$sourcedir);

    I get:

    ls: ~/Documents/bin/pdfs: No such file or directory

    However if I copy the path from the error message and paste it onto
    the command line behind 'ls' [ ls ~/Documents/bin/pdfs ], then the
    shell lists the directory.

    In an earlier try, I mounted the Samba volume via the Mac GUI and
    pointed the script to something like /Volumes/pdfs. In that case it
    found the files I was looking for.

    Since I want this to run on a crontab and can't count on the volume
    being mounted in the middle of a random night, I wanted to script the
    Samba connection. Since I couldn't count on the volume NOT being
    mounted either, I begin by unmounting anything that might already be
    at that point.


    John Campbell
     
    John, Sep 9, 2009
    #1
    1. Advertising

  2. John

    John Guest

    > Your shell is expanding ~/Documents/bin/pdfs into something like
    > /Users/jfcampbell/Documents/bin/pdfs.
    > You need to expand the '~'. The simplest way is probably
    >
    > $sourcedir =~ s/^~/$ENV{HOME}/;


    Or, I can spell out /Users/jfcampbell/Documents/bin/pdfs as a
    constant.

    Though I can't count on the Samba share being mounted all the time, I
    can be reasonably sure the user name will be good for the life of the
    script.

    Thanks.
     
    John, Sep 10, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jon wackley

    iis 5 virtual directory on samba share

    jon wackley, Dec 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,906
    jon wackley
    Dec 30, 2003
  2. William Park

    (patch for Bash) GTK+2 + Bash

    William Park, Jul 11, 2005, in forum: XML
    Replies:
    3
    Views:
    2,334
    William Park
    Jul 14, 2005
  3. KimHoon
    Replies:
    4
    Views:
    583
    Jack Klein
    Sep 20, 2003
  4. Replies:
    3
    Views:
    375
    perchef
    Aug 16, 2005
  5. Almad
    Replies:
    1
    Views:
    271
    Almad
    Nov 6, 2006
Loading...

Share This Page