Mounting Samba (Windows) drive via shell script

This question is for the seasoned Unix geeks among us.
I have a `zsh' script (read bash/ksh on steriods) at work that prepares my build environment prior to running an Ant script (read `make' for Java). The Ant script actually looks for code that is on a shared directory, usually mounted over Samba (cifs). If I forget to manually mount this drive (Finder > Go > Connect to Server...) then the script will bomb.
Now, I have tried various attempts at using the `mount_*' commands, but can't seem to get them to actually mount a drive. I'm fairly certain that `mount_smbfs' is what I want to use, but calling it doesn't seem to work as the `man' file suggests. Naturally, I want to add this mounting call to my environment setup prior to calling the build script.
Any tips from a seasoned Unix hack out there? Thanks!
Tim

There is a unix forum here which would be a better place for this question, but I believe the problem is you haven't created a mount point in the Volumes folder which would then be the path argument.
Here is the examples from the mount_afp
EXAMPLES
The following example illustrates how to mount the afp volume server.com-
pany.com/volumename/ at the mount point /Volumes/mntpnt:
mkdir /Volumes/mntpnt
mount_afp afp://username:[email protected]/volumename/ /Volumes/mntpnt
This example shows the proper url to use to mount the volume guestVolume
from the afp server myserver as guest:
mkdir /Volumes/guest
mount_afp "afp://;AUTH=No%20User%20Authent@myserver/guestVolume" /Volumes/guest
This example shows the proper url to use to mount the volume myVolume
from the afp server myserver using Kerberos authentication:
mkdir /Volumes/myVolume
mount_afp "afp://;AUTH=Client%20Krb%20v2@myserver/myVolume" /Volumes/myVolume

Similar Messages

  • Launchd won't send email via shell script

    I'm trying to send an email via shell script. e.g. my shell script is something like this:
    #!/bin/sh
    echo testing | mail -s 'this is a test' [email protected]
    My launchdaemon runs the script: /usr/local/scripts/testscript.sh
    I know the script is working, because I added some debugging (I added a line: echo is this working and sure enough, "is this working" is showing up in the console) but the email part kicks off an error message about 30 seconds later: Stray process with PGID equal to this dead job: PID ### PPID 1 sendmail
    The script works when I run it with a cron job. But why wouldn't it work as a launchd item? And why is it I'm only having problems with the email segment of my scripts? I've tried other scripts and they all seem to work fine.

    There are no errors reported. I'm looking in /var/log/mail.log.

  • Mount USB/Firewire drive from shell or cron job

    Is there a way to mount a USB/Firewire drive from the shell or possibly mount it using a cron job? Here's the situation. I have a user that keeps all of her data on her desktop or in her Documents folder. I have attached a firewire drive to her PowerMac G5 (OS 10.4.6) and successfully created cron jobs to backup her entire user folder every night. The problem is that she logs off of her computer before she leaves work. When she logs of the firewire drive unmounts and the cron job fails because it cannot find the drive. I was hoping there was a way to mount the drive using a script so that it will mount, let the cron job run, and then possibly unmount the drive afterwards. Any help with this would be much appreciated.
    MacMini, PowerMac G5, iMac   Mac OS X (10.4.7)  

    Try adding the following line to the beginning of the job:
    mount -a
    You may need to add u and/or w to the command after the a without any additional spaces for the mount to work properly.
    (13951)

  • Desktop Icon for mounted Samba/Windows share

    Hi All,
    I have recently moved over to Leopard and have found somthing to be missing that was enabled by default (it seems) in Tiger.
    If I mount a Samba/Windows share, there is no icon automatically placed on the desktop (as with USB drives etc) but there was in Tiger. I basically used these icons to know when finishing up for work at the end of the day if there were still any shares mounted before putting my machine to sleep so I would remember to unmount them. Now I don't have the visual cue, so I often get home and Finder locks up a bit and eventually tells me that the shares have been disconnected.
    Is there any way to turn this feature back on?

    Wow. I feel so stupid. I'm pretty sure I even looked in there and somehow missed it. I think I was looking for something similar to the check box list there is for the sidebar in the Finder preferences.
    Thanks for that.

  • BI Admin Tool - Setting connection pool via shell script - Is it possible?

    Hi,
    Here's the problem I am trying to solve.
    I am using a J2EE application that uses OBIEE for reporting.
    The *.rpd file is installed at a particular location when our J2EE product is installed.
    I then copy the *.rpd file to the BI home on a different server using a shell script.
    The shell script that deploys the *.rpd file does the following:
    1. Shuts down BI processes that are running
    2. Deletes the old *.rpd file
    3. Copies the new *.rpd file
    4. Starts all BI processes
    I am happy with the way we have automated this process, but would like to take it one step further.
    The *.rpd file does not have the connection pool hard-coded in it. And we want to keep it that way.
    What we would like to do is - pass the connection pool parameters to the shell script (that is used for *.rpd's deployment) and have it automatically update the *.rpd file. Is it possible to do this at all? How do we go about accomplishing this?
    Or in other words - Is there a way to update the connection pools WITHOUT hard-coding it in the *.rpd file or WITHOUT using the BI Administration Tool.
    Currently, we manually update the connection pools in the Physical Layer using the Oracle BI Administration Tool.
    The version of BI Administration Tool being used is 10.1.3.3.1 installed on a Microsoft Windows XP Professional SP2 machine. The BI Server itself is running on an Oracle Enterprise Linux 4.0 box.
    Do let me know if you need more information that would help answer this question.
    Thank you.

    Thank you - fiston and Gagan.
    I am going with fiston's solution - since it is easier to implement. I am on the QA team and the automated deployment is to lessen QA's deployment time.
    While one of our developer's said that she prefer's Gagan's solution - it would be over-kill to make changes to the application's schema for the said purpose.
    I will further make another post as to whether or not the automated deployment worked for us.

  • Hiding terminal window when running shell script?

    Hi,
    I've set up a shell script (myscript.command) to run an application with certain launch arguments. When I execute the script the app runs fine, but I get a residual terminal window.
    How can I hide it immediately after the app launch, or, preferably, avoid seeing it in the first place?
    Thanks!
    Guy

    A .command script is really just a data file for Terminal.app, which is why a terminal opens. One solution is to convert it to be its own .app (i.e., it would run on its own instead of being run by something else). I think platypus and dropscript are the two standard tools for doing that.

  • DHCP request at system startup via shell script

    Hi all,
    I administer about 120 macs and a couple of weeks ago the network admin changed the ipv4 network and the dhcp-leases, -ranges.
    My macs do not get an ip address when they start up.
    It takes about one minute until the request is succeeded.
    I am about to write a shell script that starts a dhcp request over the network.
    I want to use the same command that the network system pref (Renew DHCP Lease) uses.
    I read the bootpd, xinetd, lookupd manual but I am not sure wich one is the correct deamon to use.
    Someone can help?
    Thanks in advance
    Cheers Thorsten

    Seen the ipconfig yet?
    http://developer.apple.com/documentation/Darwin/Reference/ManPages/man8/ipconfig .8.html
    Two ways to renew a lease in Terminal, adjust your enNUMBER accordingly...
    sudo ipconfig set en0 BOOTP;sudo ipconfig set en0 DHCP
    sudo ifconfig en1 down;sudo ifconfig en1 up

  • Add a config item to windows computer via powershell script

    Hello All
    I am looking for a script which will add a config item into windows computer . I have some thing like this which will add the configuration item into an incident . But I want to add to a computer record in all windows computer. I think I am failing to find
    the source for windows computer records
    $incident    
    = get-scsmclass
    m.incident$ |get-scsmobject
    -filter "DisplayName -eq 'IR8 - test'"
    $computer    
    = get-scsmclass
    Microsoft.Windows.Computer$|get-scsmobject
    -filter "PrincipalName -eq 'test'"
    $relationship
    = Get-SCSMRelationshipClass
    -name System.WorkItemAboutConfigItem
    New-SCSMRelationshipObject
    -Relationship $relationship
    -Source $incident
    -Target $computer
    -bulk

    I really don't understand what your are trying to do. do you want to add a new windows computer object to the database, or add an existing windows computer object to the list of related items on a work item? 
    if you are trying to create a windows computer by hand, i would recommend against it. there are much easier ways to get that data from SCCM or AD via connectors. maybe you could elaborate on your need?
    If you are trying to relate an existing windows computer to a work item, then your script is correct. you just need to get the computer object in one hand, the work item in the other and mash them together with a New-SCSMRelationship around the correct Relationship
    class. remember that About (System.WorkItemAboutConfigItem) is for the Affected config item, where as Relates (System.WorkItemRelatesToConfigItem) is for the related config items. an arrow affects the target and is related to the archer; don't get them confused.
    the only other interpretation (and the one i find least likely) is that you are trying to relate two computers together, in which case the script is still correct, except, obviously, the relationship class should be System.ConfigItemRelatesToConfigItem,
    and you would need to get a windows computer in each hand. 

  • Using launchctl command within a shell script

    I have successfully installed two daemons, and I would like to be able to disable and enable them via shell scripts, called by the daemons themselves. Here is my first shell script:
    #!/bin/sh
    # Testing for presence of a CODEBOY file
    if [ -e "/Volumes/CODEBOY/Change.txt" ]
    then
    osascript '/Users/praxisii/Library/Scripts/MacScript.scpt'
    launchctl unload -w '/Users/praxisii/Library/LaunchDaemons/WaitDaemon.plist'
    launchctl load -w '/Users/praxisii/Library/LaunchDaemons/RunDaemon.plist'
    fi
    The daemon works just fine, running the background, calling this script, which is waiting for me to plug in my flash drive (entitled CODEBOY). When the flash is plugged in, the applescript is called, and the first launchctl command is executed, which disables the WaitDaemon. As advertised, the .plist file is re-written with the Disabled key set to true. The next line (which is supposed to enable the RunDaemon) is never executed.
    Similarly, if the launchctl line is placed before the osascript line, the applescript is never called. It is as if the shell ignores everything after a single launchctl command, which it will execute.
    Any ideas or comments?

    Gary:
    Thank you for the link to the TN2083. Long, but very informative.
    I appreciate all the other comments on this thread. I am an amateur AppleScript/UNIX scripter, and any opportunity to learn more is much appreciated.
    I have completely re-worked my original launchd agent system for automatic processing of a file on a flash drive. Here is the .plist file that I now use:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>RunOSAscript</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Program</key>
    <string>/usr/bin/osascript</string>
    <key>ProgramArguments</key>
    <array>
    <string>osascript</string>
    <string>/Users/casdvm/Desktop/AutoFlash.scpt</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>ServiceDescription</key>
    <string>Runs Applescript directly</string>
    <key>StandardOutPath</key>
    <string>/Users/casdvm/Desktop/AutoFlashLog.txt</string>
    <key>StartInterval</key>
    <integer>25</integer>
    </dict>
    </plist>
    The AutoFlash.scpt is an Applescript that simply uses the Finder to check for the presence of a specific file on the flash drive. If it is there, and a certain script property has a value of 2, then it runs the AppleScript that processes the desired file on the flash drive. Once that is done, the script property is set to 0 (to prevent the processing from happening over and over again.). Once the flash drive is removed, the script property is set back to 2 in anticipation of the next time the flash drive is plugged in.
    It is much simpler than the two agents I was messing with beforehand. I did indeed discover that this .plist needs to be saved in the LaunchAgents folder of my user Library (thanks again for pointing that out, Gary).
    The only problem that I have involves the continuous calling of the Applescript from the launchd agent. As you can see from my .plist file, that AppleScript is called every 25 seconds. I tried setting it up using the OnDemand key, but I kept receiving a re-spooling error of some sort (I don't recall exactly; my notes are sketchy on that phase of testing), so I just decided to have it go every 25 seconds. It really doesn't matter, since I can leave the flash drive plugged in all day anyway, and it only processes the desired file once.
    Thanks again for all the commentary and discussion; I am grateful for the assistance.
    Craig Smith

  • Shell script ftp

    Hi
    My ext 4tb (2x2TB raid 0) failed this week. HDD 2 failed to be more specific.
    Ive managed to get some functionality back but cant get into the file structure
    I was hoping to see if I could get in via shell script. Nopt used this before but given I could loose 3tb of movies and music I will try anything...
    Anyone have any gidance on using shell script to access an external network drive?
    I can ftp to the drive.
    Si

    Hi Friend,
    Can you check this link  will help you some extend : [FTP open file;
    Regards,

  • Oracle declare function in shell script

    Please tell me oracle declare function now able to run in shell script?
    I am calling in shell script like @/myscript.sql it is not working properly, reset update and other oracle command is working fine in shell script.

    I am running below code.
    #!/bin/sh
    sqlplus system/manager@prod_db <<ENDOFSQL
    update apps.fnd_concurrent_queues set node_name = 'host1', target_node ='host1' where node_name='host3';
    update apps.fnd_concurrent_queues set node_name = 'host2', target_node ='host2' where node_name='host4';
    commit;
    DECLARE
    VALUE BOOLEAN;
    l_node_id number;
    BEGIN
    select node_id into l_node_id from fnd_nodes where NODE_NAME = 'host5';
    VALUE := fnd_profile.save ('NODE_TRUST_LEVEL', 3, 'SERVER',l_node_id,null,null);
    END;
    ENDOFSQL
    Below ERROR i am getting after running above code via shell script with oracle user
    SQL>
    0 rows updated.
    SQL>
    0 rows updated.
    SQL>
    Commit complete.
    SQL> SQL> DECLARE
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 5

  • Mounting/unmounting firewire disk via LaCie shortcut button

    I wrote this little script to be ran everytime i push the button on my firewire disk.
    tell application "Finder"
    if not (disk "LaCie" exists) then
    do shell script "diskutil mount " & last word of (do shell script "diskutil list | grep 'Apple_HFS LaCie'")
    else
    tell application "Finder"
    activate
    eject disk "LaCie"
    end tell
    end if
    end tell
    Is there an easier way to do this, without the shell-call for mounting the disk. Ie can i tell finder to mount a disk by name?
    Regds,
    Martin Bergman

    Hi and welcome
    Their are quite a few ways to do what you ask.
    tell application "Finder"
    update desktop
    if not (exists disk "VOLUME NAME") then mount volume "afp://00.00.00.00/VOLUME NAME"
    end tell
    you can change out the mount volume areas to any one of these suggestions below
    --mount volume as guest, just add ip and volume name, this has no user authentication.
    mount volume "afp://;AUTH=No User [email protected]/VOLUME NAME"
    --mount volume, just add ip and volume name, and user authentication.
    mount volume "afp://Macintosh HD:[email protected]/Macintosh HD"
    --mount volume from a pc, just add ip and folder name
    mount volume "smb://00.00.00.00/HOTFOLDERS"
    --mount volume
    mount volume "afp://[email protected]"
    hope this helps
    Budgie

  • [SOLVED] advanced shell script for mount and unmount samba share

    Good morning guys,
    Today I've a very long question....
    Hope in your help....:
    I usually move from different network.
    For one of those I need to mount some share that are under an ActiveDirectory server.
    To do that I use samba.
    Especially I've made and use the below  shell script.
    I know that it's so stupid but I'm a very newbie:
    #!/bin/sh
    echo "This is a custom script for mount my citrix share"
    echo "Please insert user password (must a sudoer user)"
    echo " "
    sudo mount -t cifs -o username='myusername',password='mypassword' //host_ip/TsHome$/myusername /home/myuser/samba_share/TsHOME
    sudo mount -t cifs -o username='myusername',password='mypassword' "//host_ip/direction" /home/myuser/samba_share/direction
    echo " "
    read -p "Press ENTER key to close this terminal"
    exit
    As I say the script work but it's so crude...!
    I want/need to implement it whit the follow addictions:
    1. print a feedback on mount: somenthing like "TsHOME is now mounted" or "unable to mount TsHOME"
    2. check if the share are already mounted: to prevent accidentally multiple mount. If a share is already mounted I want to print something like "TsHOME is already mounted on /home/myuser/samba_share/TsHOME"
    3. ask for share password  (now it's in clear on script) - This is optinal
    4. un-mount the share before reboot or shutdown command. That because I've notice that If i reboot or shutdown without manually un-mount the share the step of unmounting network file system became very slow
    If it's no extremely difficult, can someone help me to write this script?
    I know that man exist but I'm not a programmer and it's so difficult for me approch it.
    Thank you in advance.
    Ale
    Last edited by Alexbit (2010-09-23 21:29:13)

    Thank you very (VERY) much!
    I've follow your information and.. it work!
    If can be usefull to other this is the complete script:
    #!/bin/sh
    echo "This is a custom script for mount citrix share"
    echo "****************************************"
    echo " "
    echo "Please insert domain password:"
    read -s mypassword
    echo " "
    echo "|checking mount state...in share are not mounted mount it!|"
    echo "+-------------------------------------------------------------------------+"
    if grep "TsHome" /etc/mtab &>/dev/null; then
    grep "TsHome" /etc/mtab | awk '{print "TsHome is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" //ipaddress/TsHome$ /home/Samba_share/TsHOME && echo "TsHOME is now mounted" || echo "unable to mount TsHOME"
    fi
    echo " "
    if grep "direction" /etc/mtab &>/dev/null; then
    grep "direction" /etc/mtab | awk '{print "direction is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/direction' /home/Samba_share/direction' && echo "direction pat is now mounted" || echo "unable to mount direction"
    fi
    echo " "
    if grep "Area" /etc/mtab &>/dev/null; then
    grep "Area" /etc/mtab | awk '{print "Area is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/Area' /home/Samba_share/Area && echo "Area is now mounted" || echo "unable to mount Area"
    fi
    echo " "
    echo "All DONE!"
    echo " "
    read -p "Press ENTER key to close this terminal"
    exit
    I don't really well understand what I've to put in rc.local.shutdown....
    I think somethings like:
    #!/bin/bash
    # /etc/rc.local.shutdown: Local shutdown script.
    echo "This is a custom script for UN-mount citrix share"
    echo "********************************************"
    echo " "
    echo "|check mount state: if mount then un-mount!|"
    echo "+-------------------------------------------------------+"
    echo " "
    if grep "TsHome" /etc/mtab &>/dev/null; then
    grep "TsHome" /etc/mtab | awk '{print "TsHome is NOT mounted -> going on..." $2}'
    else
    sudo umount /home/Samba_share/TsHOME && echo "TsHOME is now UN mounted" || echo "unable to UN-mount TsHOME"
    fi
    echo " "
    if grep "direction" /etc/mtab &>/dev/null; then
    grep "direction" /etc/mtab | awk '{print "direction is NOT mounted -> going on.." $2}'
    else
    sudo umount /home/Samba_share/direction && echo "direction is now UN mounted" || echo "unable to UN-mount direction pat"
    fi
    echo " "
    if grep "Area" /etc/mtab &>/dev/null; then
    grep "Area" /etc/mtab | awk '{print "Area is NOT mounted - Finished" $2}'
    else
    sudo umount /home/Samba_share/Area && echo "Area is now UN mounted" || echo "unable to UN-mount Area"
    fi
    echo " "
    echo "going shutdown"
    echo " "
    sleep 5
    I've try but it seems to ignore the IF statement... this is the output when ALL share are UNmounted:
    $ sh /etc/rc.local.shutdown
    This is a custom script for UN-mount citrix share
    |check mount state: if mount then un-mount!|
    +-------------------------------------------------------+
    umount: /home/Samba_share/TsHOME: not mounted
    unable to UN-mount TsHOME
    umount: /home/Samba_share/direction: not mounted
    unable to UN-mount direction
    umount: /home/Samba_share/Area: not mounted
    unable to UN-mount Area
    going shutdown
    Tomorrow I will test again when I'm at office.
    Meanwhile can you check if I made a macroscopic mistakes?
    Thank you again!
    Last edited by Alexbit (2010-09-23 17:34:49)

  • Shell script to mount/unmount Vista laptop samba shares?

    I have a couple Vista laptops in the house that I take to the office regularly, and currently I use Dolphin to browse into the laptop and xfer files back and forth, but I really don't want to use dolphin, I'd rather set up some kind of script/alias that can prompt me to mount and unmount the share instantly in shell, instead. Is this possible or do I just have to do it in fstab and issue mount/unmount commands everytime?
    TIA for any help

    I tested on a USB stick, no probs, I put my USB stick in a slot, waited for it to mount, ran the script using the "unmount first", then ran the "mount" second worked fine after that using the "unmount " part of the script, I found though that if I right clicked "eject" that the script would not mount the volume.
    You could try something as simple as the below maybe.
    tell application "Finder"
    eject "LEXAR MEDIA"
    end tell
    set _VolumeName to "LEXAR MEDIA"
    set deviceName to do shell script "diskutil list | grep \"" & _VolumeName & "\" | awk '{print $6}'"
    --do shell script "diskutil mountDisk /dev/" & deviceName --mount
    do shell script "diskutil unmountDisk /dev/" & deviceName --unmount
    Budgie

  • How do I re-mount an external drive in Lightroom 2 running on Windows 7?

    I am using Lightroom 2 and have moved many picture folders to an external drive.  Now when I reconnect the external drive Lightroom shows the drive as offline.  I need to know how to re-mount the drive.  I am running Windows 7 and can not fine the disk utility in Lightroom 2.

    Lightroom does not have a disk utility.
    a) Make sure the drive is visible and accessible via <My Computer>. If it is visible in <My Computer>, Lr should also see it as connected.
    b) If it is not check if the power for the drive is <ON> and remove and re-connect the USB / Firewire / eSata cable.
    c) If this doesn't help: Check in <My Computer> if the drive has the same drive letter as before. Sometimes Win 7 changes the drive letter, and then Lr cannot find the drive.
    In this case you have to change the drive letter to what it was before.
    d) If the drive letter has not changed and Lr still cannot see the drive, try this:
    Put one dummy photo on the external drive - via Win Explorer. It can be a copy of another photo but - in Win Explorer - change the name of the dummy photo to something descriptive.
    Then in Lr open the Import Dialog and import this dummy photo. After that Lr should see the drive and you can delete the dummy photo.

Maybe you are looking for

  • How do you close a dragged applet, as Stage.close() doesn't work?

    I'm trying to implement a close button in a draggable applet, but Stage.close() doesn't work, and there's an odd little "X" icon which is causing me problems... My starting point and example is the simple draggable applet from the API documentation.

  • Illustrator 5 - patterns problem with printing

    Hi please please help having majoy problems and need help asap in work!!! I am working on a PC windows 7 illustrator 5. when I create a pattern any type even a imple spot and fill a CAD t shirt, its fine, when I print it, it creates lines through out

  • Mail won't send, and Outbox doesn't appear

    About three days ago my mail stopped sending. When I compose mail everything goes as usual and no alert box pops up when I hit send. However, my mail isn't sending and the outbox isn't showing up to tell me the mail is still pending. I haven't found

  • Problem setting up handlers for Jetty web app

    Hello, I am encountering a problem with setting up the handlers for my web application, what I want is : Having some requests handled by an HTTPServlet with doGet and doPost methods ( how can I load JSP pages from within these methods ? ) and also be

  • No sound from my Web Cam in Skype

    [e-mail removed for privacy and security]