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

Similar Messages

  • Script to mount/unmount a USB thumb drive

    I am looking for an applescript to mount or unmount a USB thumb drive.
    I tried:
    tell application "Finder"
    do shell script "diskutil mount /dev/disk1"
    end tell
    This did not work for me

    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

  • [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)

  • [SOLVED] Bash scripts to mount & unmount optical drive in Worker?

    I'm running XFCE on Arch with the HAL daemon being called in /etc/rc.conf.
    I can access media on my optical drive (DVD's or CD's) through the desktop icon that appears after HAL has recognised the drive, VLC automatically does its thing as does NeroLinux.
    The reason I'm posting is that I found a great DOpus clone yesterday called Worker - http://www.boomerangsworld.de/cms/worker/index?lang=en, which I am in the process of configuring.
    A problem I have is being able to access the optical drive via Worker.
    The way it is on my system, with HAL handling it, the first line (see below) appears after HAL mounts the media, which basically makes the two lines below it useless:
    /media/<title of disk>
    /media/cd
    /media/dvd
    I have tried configuring Worker to use /media/dvd (or cd), to access the optical media, these don't work for the reason stated above, & /dev/sd0 doesn't work either.
    So, do I have to turn off HAL, uncomment the lines in fstab & use mount?
    A little bash script, that would do the job for me would be great, as Worker will accept a script or a command string.
    I am a bash baby, so if someone can see a solution please post it?
    All input welcome.
    Thanks.
    Last edited by handy (2008-11-19 04:11:02)

    Zariel wrote:
    i guess something like this?
    %optical ALL=(ALL) NOPASSWD: ALL
    I found the clues for this in the sudoers manual:
    handy   ALL = NOPASSWD: /sbin/umount /CDROM,\
                    /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
    Which works in so far as now mounting no longer needs the password.
    Which leaves me with the problem of trying to understand how to get Worker to mount the optical drive on command.
    If I enter the bash command in the Terminal as follows:
    mount /mnt/dvd
    the media is mounted, after which I can push the button in Worker, which I have configured with:
    /mnt/dvd
    & the root list of the optical media is displayed in the active panel of Worker.
    I just haven't been able to get Worker to use "mount /mnt/dvd" yet, there will be a way, I wonder how long it will take me to find it? lol
    Last edited by handy (2008-11-19 06:48:09)

  • Automator runs shell script differently

    hi
    i build a little shell script that mounts my network-shares when they are available - that's works perfect if run by terminal but if i run it via Automator-Run shell script it does ******** - it doesn't seem to recognize my variables and creates dirs like $“Data“  instead of just Data
    can anyone help me with that?
    #!/bin/bash
    # connects to network shares if server available
    #config - wich server and mountpoints, login
    server=$"192.168.2.1"
    serverName=$"NAS(AFP)"
    dir=$“Data“
    dir2=$“Data1“
    login=$“xxx“
    pw=$“xxx“
    #connect-test and create mountfolders
    ping -q -c3 $server > /dev/null
    if [ $? -eq 0 ];then
      if [ -d "/Volumes/"$dir"" ]; then
      echo "folder $dir exists"
      else
      echo "creating folder $dir"
      mkdir "/Volumes/"$dir""
      fi
      if [ -d "/Volumes/"$dir2"" ]; then
      echo "folder $dir2 exists"
      else
      echo "creating folder $dir2"
      mkdir "/Volumes/"$dir2""
      fi
    #mount
      mount_afp "afp://"$login":"$pw"@"$serverName"._afpovertcp._tcp.local/"$dir"" "/Volumes/"$dir""
      mount_afp "afp://"$login":"$pw"@"$serverName"._afpovertcp._tcp.local/"$dir2"" "/Volumes/"$dir2""
      echo „ping ok“
    else
      echo „failed to connect to $serverName“
    fi

    FYI.  If you create an Alias of a mounted volume, the Alias will record all the connection information, except the password.  If your keychain is not locked, then when double clicking on the Alias, it will get the password from the keychain and mount the networked volumes (assumes you allowed the password to be stored in the keychain when you first mounted the volumes interactively).
    The Aliases can be put into your System Preferences -> Users & Groups -> Startup Items if you like.
    If this is a laptop and you are re-mounting the volumes when you get to a specific location, you might want to look at ControlPlane
    <http://www.macupdate.com/app/mac/39644/controlplane>

  • 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

  • Non-root user cannot umount a SAMBA share if there is "SPACE" with the

    I already post this to the bugs report http://bugs.archlinux.org/task/9672, but I would like to see if someone in the forum can help.
    Description:
    If there are "SPACE" in the SAMBA share name. Then, a non-root user can mount that share, but cannot umount it with "umount" command. It gives "mount desagrees with the fstab" error. root can mount/umount without any problem.
    Also, user can umount the share by "smbumount" without any problem.
    Additional info:
    * package version(s)
    samba 3.0.28A-1
    util-linux-ng 2.13.0.1-2
    * config and/or log files etc.
    /etc/fstab
    Steps to reproduce:
    1. Add a line in /etc/fstab as the following
    //QNAP-500GB/USB\040Disk\0401 /mnt/eBooks smbfs workgroup=GROUPNAME,username=xxxxxx,ip=xxxxxxxx,password=xxxxxx,noauto,noatime,users,rw 0 0
    as you can see that SAMBA share name "USB Disk 1" was replace by "USB\040Disk\0401".
    2. Change UID of/usr/bin/smbmnt and /usr/bin/smbumount by
    chmod u+s /usr/bin/smbmnt
    chmod u+s /usr/bin/smbumount
    3. Change the ownership of the mount path for this SAMBA share to a non-root user by
    chown username:users /mnt/eBooks
    4. mount as a non-root user (username)
    mount /mnt/eBooks
    5. ERROR! if umount as a non-root user; NO ERROR if umount as root.
    [ning@HP-m8100y ~]$ umount /mnt/eBooks/
    umount: /mnt/eBooks mount disagrees with the fstab
    6. This SAMBA share can be umounted by
    smbumount /mnt/eBooks

    Did you try using %20 instead of a space?  I know it works for URLs...worth a shot.

  • Mount script for ext2 - mixing applescript and shell script

    Hello
    i want to do a .app using the ScriptEditor to get my external usb-disc mounted.
    I tried ExtFS Manager before, but was not as happy with it.
    so the basic idea is some kind of mixture of apple script and bash-shell script, but im not sure how to combine it.
    shell script:
    #!/bin/sh
    sudo kextload /Library/Extensions/ext2fs.kext
    mkdir ~/usb_music/
    sudo mount -t ext2 -o nosuid,w,m=777,user /dev/disk1s5 ~/usb_music/
    sudo chmod a+rwx ~/usb_music/
    apple-script:
    on run
    try
    do shell script ""
    end try
    end run
    any ideas how to get it combined and working ?
    best regards
    fidel
    MacBookPro 15,4" 1,83 GHz   Mac OS X (10.4.8)  

    is there a way to implement it in a way that normal users can work with sudo to mount the drive ?
    kextload requires superuser privileges, so at some point some part of your script is going to need to run with elevated privileges.
    It is possible to configure sudo to allow non-admins to run any other commands. You could either allow non-admins to to run kextload or, preferably, allow them to run your shell script.
    man sudoers will give you the details on how to configure sudo to do this, which might be as simple as:
    <pre class=command>ALL  ALL=(ALL) /usr/local/bin/myscript</pre>
    This will allow all users to run /usr/local/bin/myscript as root.

  • [Gnome-shell] Desktop freezes when Samba shares become unavailable

    Hi,
    I'm experiencing a very annoying problem on the laptop I use at work. I'm using an up-to-date Arch with Gnome-shell and we have a bunch of network shares on several servers.
    I access them via Nautilus and everything's fine as long as I don't unplug the cable. If I do that while Samba shares are mounted in Nautilus (through GVFS), the entire desktop freezes and I have to restart GDM to get it back (but all applications are killed and that's not cool).
    I also realized that when I mount a Samba share I'm accessing through a personal VPN (so, through the Internet), the entire desktop becomes slow and choppy. If I transfer a file to the remote folder using Samba over this VPN, I cannot do anything until the transfer is finished. During this time the desktop is freezed. But after that I get it back and it's working again (but is still slow as long as I keep the share folder mounted).
    When I unmount the "slow" Samba shared folder, everything works perfectly.
    Why is Gnome so dependent on such thing as a simple mounted shared folder? Is there a way to prevent this behaviour?
    Thanks in advance

    Hi nanawel, i've a very similar problem to your on my home machine: this (https://bbs.archlinux.org/viewtopic.php?pid=1196319) is the thread i found when researching my problem, so i started investigating it and then discovered the samba shares problem, so i found out your problem when looking up for similar annoyances in Google.
    Have you been able to track it down?
    As i said in the other thread, i don't have installed any of those gnome-shell extensions, but i have the TweakTool->Desktop option named "Show mounted volumes on the desktop" enabled, as well as an entry in my /etc/fstab file: tomorrow i'm going to have some tries with my brother's pc and see if i can find out something more.. i'll keep posting on this thread then, since it looks like my problem is very very similar.. hopefully we'll be able to track it down this beast.
    But also, I'm also experiencing that "slow network share/choppy desktop" on my work machine only: it looked like a FUSE issue, but could never debug that since i've a quite important deadline at work and can't start debugging my OS during working hours
    Anatolik was kind enough to chime in and suggest to debug it (https://bbs.archlinux.org/viewtopic.php … 7#p1193437), this is the thread about it.

  • Mount/unmount 2nd internal drive (mount working)

    So I can't seem to figure out whats wrong with my script, any help would be greatly appreciated;
    So when I run it, it will mount the drive if it is unmounted, but it won't unmount the drive when run
    set diskName to "OptiBay"
    tell application "Finder"
              if disk diskName exists then
      eject disk diskName
              else
                        tell current application
                                  set deviceLine to (do shell script "diskutil list | grep \"" & diskName & "\" | awk '{ print $NF }' ")
                                  if deviceLine = "" then
                                            display dialog "The disk \"" & diskName & "\" cannot be found." buttons {"OK"} default button 1 with title "Error" with icon caution
                                  end if
                                  set foundDisks to paragraphs of deviceLine
                                  repeat with i from 1 to number of items in foundDisks
                                            set this_item to item i of foundDisks
                                            if this_item contains "disk" then
                                                      do shell script "diskutil mountDisk /dev/" & this_item
                                            end if
                                  end repeat
                        end tell
              end if
    end tell

    Hello Mavric,
    Did you resolve this issue?
    I am looking for a script that will completely "eject" a drive (with two partitions) int he Superdrive bay. The result I want is for the HDD there to spin down completely. Your solutions looks like it might do the trick... although I'd have to get it to "eject" one drive with two petitions.

  • Port AppleScript to bash shell script

    Hi all,
    I made this script with the help of Neil from these forums. The purpose of the scrip is so that my friend can set up a share point on his NAS which is simply full of links so that if people access the NAS (its full of music and movies) if the delete a link, the file stays where it is.
    The issue he has now, is that when he make the links in MacOS, a Windows system will no follow them. Is there a way around this or should the script be ported to a bash script so that the links can be created internally on his BSD NAS.
    Thanks for any help and suggestions.
    set these_items to (choose file with prompt "Choose files to link:" with multiple selections allowed)
    set link_folder to (choose folder with prompt "Choose folder to place links in:")
    repeat with this_item in these_items
    tell application "Finder" to reveal this_item
    set this_path to the quoted form of the POSIX path of this_item
    set shell_folder to the quoted form of the POSIX path of link_folder
    do shell script "ln -s" & space & this_path & space & shell_folder
    end repeat
    end

    Your issue is one of symlink support, so it won't matter how you create the symlinks.
    First off, which version of Windows are you running?
    Only later versions of Windows (Win7 and, I think Vista) support symlinks, so if you're using anything earlier it won't work.
    Secondly, if you're pointing to a network volume then the target paths have to match, and that's likely to be a problem in cross-platform environments. That's because the symlink file really just contains the path to the target and your paths may be different on each OS.
    For example, On your Mac the sharepoint might be mounted at /Volumes/server and your file might be at /path/file on that share.
    So your symlink file will contain '/Volumes/server/path/file'
    No Windows system is going to be able to follow that path since disks aren't mounted under /Volumes. You would either have to know that share's current mount point or use a Windows path of the form \\server\share\path\file but that latter form won't work on non-Windows systems.
    So the short answer is that you probably have to create two sets of links, one for the Windows users and one for the Macs. There's no simple, universal, cross-platform symlink standard that will do what you want (at least that I'm aware of).

  • Suspend fails when samba shares are mounted

    I have a weird problem with my laptop when I try to suspend to ram.
    If no samba share is mounted, then it suspends OK.
    If there is a samba share mounted, when I suspend through KDE menu or by the command "pm-suspend", then it fails to suspend, and in /var/log/pm-suspend I see the line "s2ram_do: Device or resource busy". If I type the command " s2ram -f" then it suspends OK.
    I have created a hook that executes "umount -a -t cifs" and now it suspends, but only if the samba share is available. If it is an unavailable it still fails to suspend.
    Does anyone has the same problem or a solution to this?
    P.S. I hope I posted in the correct category...

    Hi nanawel, i've a very similar problem to your on my home machine: this (https://bbs.archlinux.org/viewtopic.php?pid=1196319) is the thread i found when researching my problem, so i started investigating it and then discovered the samba shares problem, so i found out your problem when looking up for similar annoyances in Google.
    Have you been able to track it down?
    As i said in the other thread, i don't have installed any of those gnome-shell extensions, but i have the TweakTool->Desktop option named "Show mounted volumes on the desktop" enabled, as well as an entry in my /etc/fstab file: tomorrow i'm going to have some tries with my brother's pc and see if i can find out something more.. i'll keep posting on this thread then, since it looks like my problem is very very similar.. hopefully we'll be able to track it down this beast.
    But also, I'm also experiencing that "slow network share/choppy desktop" on my work machine only: it looked like a FUSE issue, but could never debug that since i've a quite important deadline at work and can't start debugging my OS during working hours
    Anatolik was kind enough to chime in and suggest to debug it (https://bbs.archlinux.org/viewtopic.php … 7#p1193437), this is the thread about it.

  • How to solve this problem in shell script: unexpected end of file

    Hello,
    I need to connect to each databases listed in /etc/oratab and check which database is shutdown(or mounted-only) and which database is opened to accept connection. However, following shell script gives me this error message:
    $>./check_is_db_runing.sh
    ./check_is_db_runing.sh: line 39: syntax error: unexpected end of file
    Could anyone please help me to solve this problem, why the code (line 29 to 32) does not work in the LOOP? It works without the LOOP.
    Thanks in advance!!!
    1 #!/bin/bash
    2
    3 LOGDIR=/data03/oracle/dbscripts
    4 ORATABFILE=/etc/oratab
    5
    6 cat $ORATABFILE | while read LINE
    7 do
    8 case $LINE in
    9 \#*) ;; #comment-line in oratab
    10 *)
    11 ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
    12 if [ "$ORACLE_SID" = '*' ] ; then
    13 # NULL SID - ignore
    14 ORACLE_SID=""
    15 continue
    16 fi
    17
    18 # Proceed only if last field is 'Y'
    19 if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
    20 if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
    21
    22 ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
    23 PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
    24 export ORACLE_SID ORACLE_HOME PATH
    25 LOGFILE=$LOGDIR/check_$ORACLE_SID.log
    26 touch $LOGFILE
    27 #echo $LOGFILE
    28
    29 $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
    30 select * from global_name;
    31 exit
    32 EOF
    33
    34 fi
    35 fi
    36 ;;
    37 esac
    38 done

    This code works ie. generates logs with sql result - slightly modified to be runable:
    #!/bin/bash
    LOGDIR=/tmp
    ORATABFILE=/etc/oratab
    cat $ORATABFILE | while read LINE
    do
    case $LINE in
    \#*) ;; #comment-line in oratab
    ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
    if \[ -z $ORACLE_SID \] ; then
    # NULL SID - ignore
    ORACLE_SID=""
    continue
    # Proceed only if last field is 'Y'
    else
    ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
    PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
    export ORACLE_SID ORACLE_HOME PATH
    LOGFILE=$LOGDIR/check_$ORACLE_SID.log
    touch $LOGFILE
    #echo $LOGFILE
    $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
    select * from global_name;
    exit
    EOF
    fi
    esac
    done

  • How I run a shell script from the scheduler on 10.2.0.2.0 ?

    Hello Oracle People,
    I'd like to run a shell script from the Scheduler in my 10g database.
    Right now it is a simple shell script.
    Eventually it will wrap RMAN commands to back up my DB.
    I wrote a simple pl/sql script to create a job:
    -- cr_job10.sql
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'my_backup_job',
    job_type => 'EXECUTABLE',
    job_action => '/h/oracle/scripts/tst.sh',
    start_date => '06-SEP-07 5.33.00PM US/Pacific',
    repeat_interval => 'FREQ=DAILY',
    end_date => '08-SEP-07 4.00.00PM US/Pacific',
    enabled => TRUE,
    comments => 'My Backup Job');
    END;
    I see no errors when I run the above procedure.
    I checked DBA_SCHEDULER_JOBS and the job is in there.
    The scheduler, though, errors out with an error which I see in a trace file:
    /h/oracle/admin/orcl/bdump/orcl_j000_22396.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    ORACLE_HOME = /h/oracle/product/10r2
    System name: SunOS
    Node name: sol
    Release: 5.10
    Version: Generic_118855-14
    Machine: i86pc
    Instance name: orcl
    Redo thread mounted by this instance: 1
    Oracle process number: 15
    Unix process pid: 22396, image: oracle@sol (J000)
    *** ACTION NAME:(MY_BACKUP_JOB) 2007-09-06 17:33:00.175
    *** MODULE NAME:(DBMS_SCHEDULER) 2007-09-06 17:33:00.175
    *** SERVICE NAME:(SYS$USERS) 2007-09-06 17:33:00.175
    *** CLIENT ID:() 2007-09-06 17:33:00.175
    *** SESSION ID:(140.13520) 2007-09-06 17:33:00.175
    *** 2007-09-06 17:33:00.175
    ORA-12012: error on auto execute of job 53267
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    I googled on this:
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    Google returned only 1 hit.
    There, I see some evidence that I need to configure something inside
    of Oracle to run shell scripts from the scheduler, but possibly just
    for machines running windows. I'm running Solaris.
    Do any of you know what I need to configure inside of Oracle to
    run shell scripts from the scheduler?
    -Owen

    Hello people,
    I should have added this bit of information:
    "The script runs fine from oracle's crontab."
    "The script runs fine from a shell owned by oracle."
    I'm getting responses telling me to check my env variables and permissions
    which would be helpful to a UNIX novice.
    I have a feeling that no one is using the scheduler to run RMAN scripts.
    Tim Hall suggested I take a close look at these files:
    $ORACLE_HOME/rdbms/admin/externaljob.ora
    $ORACLE_HOME/bin/extJob
    Currently I'm setup like this:
    bash sol root /h/oracle/product/10r2/bin 31 #
    bash sol root /h/oracle/product/10r2/bin 31 # ll $ORACLE_HOME/rdbms/admin/externaljob.ora
    -rw-r--r-- 1 root dba 52 Sep 7 15:29 /h/oracle/product/10r2/rdbms/admin/externaljob.ora
    bash sol root /h/oracle/product/10r2/bin 32 #
    bash sol root /h/oracle/product/10r2/bin 32 # cat $ORACLE_HOME/rdbms/admin/externaljob.ora
    # externaljob.ora
    run_user = rman
    run_group = rman
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 # ll $ORACLE_HOME/bin/ext*
    -rwsr-x--- 1 rman dba 30388 Sep 21 2006 /h/oracle/product/10r2/bin/extjob*
    -rwsr-x--- 1 rman dba 30392 Sep 21 2006 /h/oracle/product/10r2/bin/extjobo*
    -rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc*
    -rwxr-xr-x 1 oracle dba 300 Sep 21 2006 /h/oracle/product/10r2/bin/extusrupgrade*
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    On my system, the user 'nobody' has no shell so I cannot use nobody.
    I created a user named rman:
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 # su - rman
    Sun Microsystems Inc. SunOS 5.10 Generic January 2005
    $
    $ id
    uid=220(rman) gid=220(rman)
    $
    $
    $ date
    Fri Sep 7 16:30:03 PDT 2007
    $
    $
    Jared points out that rman needs access to extproc:
    $ ls -la /h/oracle/product/10r2/bin/extproc
    -rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc
    $
    $
    Here is a demo of rman running his script:
    bash sol root /h/oracle/product/10r2/bin 35 # su - rman
    Sun Microsystems Inc. SunOS 5.10 Generic January 2005
    $
    $
    $ ls
    scripts
    $
    $
    $ scripts/tst.sh
    $
    $
    $ cat scripts/tst.sh
    #! /bin/sh
    /usr/bin/date > /tmp/tst.sh.out.txt 2>&1 &
    exit 0
    $
    $
    $ cat /tmp/tst.sh.out.txt
    Fri Sep 7 16:31:23 PDT 2007
    $
    $ rm /tmp/tst.sh.out.txt
    $
    I am focused on this error:
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    And I am focused on this exit code: 274662
    What does 274662 mean?
    If the Scheduler gives me an error like "274662" rather than some English,
    it's obvious to me the Scheduler is a POS and I should not use it.
    And of course,
    If I cannot run RMAN from Oracle Scheduler, I'll use cron.
    -Owen

  • SMB problems with Vista and Samba 3.0.25a

    I've got a huge problem with my network setup here. I've read the previous posts about non working samba shares, but I did not found any working tips. I have done some additional tests, and I would like to share them with you, maybe anyone finds the solution based on them.
    So the problem is that I cannot access smb based shares. Not on my Windows (Vista) workstation, and not on my freebsd server (samba 3.0.25a). Login seems to be successful. When I enter a wrong username, or a wrong password, the finder tells me that this credentials are wrong. So as far as I can see the problem must be behind the login step.
    My samba logfile does not report anything, same for the firewall logs from Leopard. When I try to list the shares from the terminal (with smbclient) it works fine. I even can mount this shares, but the goal was to have it available in the finder.
    When I use +K to mount the share the manual way, I can enter the username and password (if they are wrong, I get the right error message), but after that I get only the connecting dialog.
    Thank you very much to everyone who might have any idea how that could be fixed.
    Have a nice day.

    FYI: This issue was fixed in 10.5.2, and there is a workaround for previous versions: Remote % signs from the password.

Maybe you are looking for

  • Getting the local full path name of a file from an item File Browser

    Hi all, I would like to get the local full path name, of a file selected from an item 'File browser'. I see in wwv_flow_files the column 'name', but actually it's a kind of id like 'F1542335/myFile.gif' for example. What i want is the local path of t

  • Payment by currency

    We need to use different bank account based on the currency.  We used different bank accounts for each currency to make wire payments. We are building a custom program to generate wire details file. Where do i control to pick up bank account by curre

  • Why does my Safari screen keep zooming in?

    First off, I LOVE OSX Lion. It's the fastest system upgrade I've ever seen on a Mac. With that said, I have this problem. I'm using a Magic Mouse. Just since my Lion upgrade, while I'm in Safari, browsin', every so often it just zooms in close on the

  • Premier elements 13 what order to run installers in?

    I downloaded 3 files: 1. Akamai_NetSession_Installer.exe, 2. PremiereElements_13_LS26_win64.7z  (is this a zip file?) 3. PremiereElements_13_LS26_win64.exe. What do I run first, second, when do I extract the zip file? Thanks I could find NO installat

  • How to use urdu characters in forms6i

    I use forms6i as frontend and oracle 8i and 9i as database.I want to input URDU characters in text item using form6i and want to store the same in databse.Here majority of bussiness and oranizational data is stored in files using software inpage whic