Script to detect when USB stick is plugged

Script to detect when USB stick is plugged to my mac.
Is it possible?
Thank you!

How to invoke a Unix command from Applescript
Name: toggle-hidden
    Author: rccharles
    Copyright 2010 rccharles
    GNU General Public License
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation,  version 3
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    For a copy of the GNU General Public License see <http://www.gnu.org/licenses/>.
on run
    -- Write a message into the event log.
    log "  --- Starting on " & ((current date) as string) & " --- "
    try
        set results to do shell script "defaults read com.apple.finder AppleShowAllFiles"
        log "results = " & results
    on error errorMsg
        -- Most likely, the variable AppleShowAllFiles does not exit. 
        -- AppleShowAllFiles isn't defined in a newly created account.
        -- The write command below will create the AppleShowAllFiles variable.
        log "Error ..." & errorMsg
        set results to "FALSE"
    end try
    if results = "FALSE" then
        display dialog "Displaying all files.  Finder will restart." giving up after 2
        set the_rc to do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE  ;killall Finder"
    else
        display dialog "Hiding hidden files.  Finder will restart.." giving up after 2
        set the_rc to do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE  ;killall Finder"
    end if
end run

Similar Messages

  • My Mac Mini doesn't start up when usb devices are plugged in.

    My Mac Mini doesn't start up when usb devices are plugged in.
    It just shows the "White screen of Death" when 1 or more usb ports are used.

    Haha. I just restarted it and it worked. Instead of turning it off and on. But thanks.
    By the way:
    Note: It is possible that the SMC could encounter an issue that may cause unusual system behavior typically related to the symptoms described below. In some cases, resetting the SMC may be the only correct method to resolve the issue, however, an SMC reset should only be attempted after all other standard troubleshooting has been performed.
    So I hope it is fixed for now. But could someone also post another solution?

  • Script to detect when a radio button is clicked/ digital signature signed

    Good afternoon,
    What is the syntax to detect if a radio button is clicked or a digital signature field is signed?
    What I want to do is populate a field if a radiobox is clicked and a the user digitially signs the form.
    My radio boxes follow the scheme
    Group name: Group 1
    Choice name: A,B, C, D
    Digital signater field name: boss
    Proposed script
    if ( group1.A==True and this.getField("boss').signed){
         this.getField("x").value = thisgetField("y").value
    I know the syntax is way off but I am trying to fufil a task like thie one described above.

    Try67
    Thanks
    That works. Follow on question:
    When I digitally sign,  I am trying to get that digital signature to permeate to other digital signature blocks. I am trying to modify your code to do this once the document is digitally signed but it is giving me a syntax error:
    if ( this.getField("MainCheckbox").value=="Choice1" && this.getField("Signature155").value!="" {
         this.getField("Signature15").value! = this.getField("Signature155").value!;
        }else this.GetField("Signature15").value = "";
    How to I fix that?
    Also,  I am trying to d othe same with radio boxes; however, radio boxes do not have an option to run a script once they are checked.

  • P7N Diamond - Beeps when usb items are plugged during post

    Can i clarify that this is normal behaviour, as ive never known it with other mobo's, it beeps for each item that is plugged in after the intial post beep on bootup, should be the last of my questions hopefully.

    thanks, i think i found something in here via google, buried deep in a thread a few days ago, when i 1st built it up, confused the hell out of me. just wanted it clarified.

  • HP530 not hibernating when USB WLAN stick plugged in, works unplugged.

    This problem came up when the laptop's builtin wlan card didn't connect to our wlan because of the 13 byte key (5 byte key worked fine but my dad wants to use the 13 byte key). I tried using an external USB wlan stick which connected fine to our network. However hibernating doesn't work when the stick is plugged in. I have tried s2disk and pm-hibernate, both fail. I have also tried two different wlan sticks, hibernation fails with both.
    Buffalo Airstation Wireless-G:
    Bus 001 Device 005: ID 0411:00da MelCo., Inc. WLI-U2-KG54L
    A-Link WL64USB:
    Bus 001 Device 006: ID 0ace:1215 ZyDAS WLA-54L WiFi
    Here is how the hibernation fails. Screen goes black except a white cursor blinking in the corner. The login prompts in consoles remain active and I can change consoles with CTRL-ALT-F1 etc. Login prompts don't take keystrokes though.
    However, hibernation does work when the sticks are not connected.
    This isn't a really big problem but trying to remember plugging/unplugging the stick is quite annoying.
    Is there any way to fix this?
    P.S. I will post more after I get the logs and some other info.

    /var/log/pm-suspend.log
    Initial commandline parameters:
    Thu Jun 18 11:01:57 EEST 2009: Running hooks for hibernate.
    /usr/lib/pm-utils/sleep.d/00auto-quirk hibernate hibernate: Adding quirks from HAL: --quirk-vbe-post
    success.
    /usr/lib/pm-utils/sleep.d/00logging hibernate hibernate: Linux myhost 2.6.29-ARCH #1 SMP PREEMPT Wed May 20 07:06:02 UTC 2009 i686 Intel(R) Celeron(R) M CPU 420 @ 1.60GHz GenuineIntel GNU/Linux
    Module Size Used by
    i915 150568 2
    drm 137440 3 i915
    i2c_algo_bit 5432 1 i915
    i2c_core 20616 3 i915,drm,i2c_algo_bit
    ipv6 259252 22
    usbhid 35168 0
    hid 40064 1 usbhid
    zd1211rw 44376 0
    joydev 9536 0
    snd_seq_oss 29696 0
    snd_seq_midi_event 6004 1 snd_seq_oss
    snd_seq 47856 4 snd_seq_oss,snd_seq_midi_event
    snd_seq_device 6016 2 snd_seq_oss,snd_seq
    serio_raw 4984 0
    sg 25352 0
    psmouse 54632 0
    pcspkr 2196 0
    uhci_hcd 22404 0
    yenta_socket 23968 1
    rsrc_nonstatic 10708 1 yenta_socket
    iTCO_wdt 10584 0
    iTCO_vendor_support 2840 1 iTCO_wdt
    ehci_hcd 34688 0
    e100 30684 0
    mii 4468 1 e100
    usbcore 134576 5 usbhid,zd1211rw,uhci_hcd,ehci_hcd
    wmi 6248 0
    container 3092 0
    video 16292 0
    snd_hda_codec_conexant 19796 1
    output 2388 1 video
    snd_hda_intel 24872 0
    snd_hda_codec 60212 2 snd_hda_codec_conexant,snd_hda_intel
    snd_hwdep 6904 1 snd_hda_codec
    snd_pcm 66936 2 snd_hda_intel,snd_hda_codec
    snd_timer 19132 2 snd_seq,snd_pcm
    snd 51108 9 snd_seq_oss,snd_seq,snd_seq_device,snd_hda_codec_conexant,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
    soundcore 6112 1 snd
    snd_page_alloc 8124 2 snd_hda_intel,snd_pcm
    intel_agp 25436 1
    agpgart 29332 3 drm,intel_agp
    thermal 15056 0
    evdev 9312 9
    processor 38720 2 thermal
    fan 4056 0
    button 5700 0
    battery 9816 0
    ac 3832 0
    autofs4 23256 2
    arc4 1588 4
    ecb 2452 4
    b43 126000 0
    ssb 37848 1 b43
    rfkill 9456 1 b43
    pcmcia 33036 2 b43,ssb
    mac80211 158652 2 zd1211rw,b43
    cfg80211 36524 3 zd1211rw,b43,mac80211
    led_class 3416 1 b43
    input_polldev 3132 1 b43
    pcmcia_core 32232 5 yenta_socket,rsrc_nonstatic,b43,ssb,pcmcia
    rtc_cmos 10156 0
    rtc_core 16400 1 rtc_cmos
    rtc_lib 2324 1 rtc_core
    ext3 127100 2
    jbd 45640 1 ext3
    mbcache 6584 1 ext3
    sr_mod 14756 0
    cdrom 33856 1 sr_mod
    sd_mod 25328 4
    ata_piix 21816 3
    pata_acpi 3828 0
    ata_generic 4536 0
    libata 156908 3 ata_piix,pata_acpi,ata_generic
    scsi_mod 100404 4 sg,sr_mod,sd_mod,libata
    total used free shared buffers cached
    Mem: 1026232 479124 547108 0 31080 243848
    -/+ buffers/cache: 204196 822036
    Swap: 2048248 14304 2033944
    success.
    /usr/lib/pm-utils/sleep.d/00powersave hibernate hibernate: success.
    /usr/lib/pm-utils/sleep.d/01grub hibernate hibernate: not applicable.
    /usr/lib/pm-utils/sleep.d/11netcfg hibernate hibernate: :: pirun down [BUSY] [DONE]
    success.
    /usr/lib/pm-utils/sleep.d/49bluetooth hibernate hibernate: not applicable.
    /usr/lib/pm-utils/sleep.d/55NetworkManager hibernate hibernate: success.
    /usr/lib/pm-utils/sleep.d/75modules hibernate hibernate: not applicable.
    /usr/lib/pm-utils/sleep.d/90clock hibernate hibernate: not applicable.
    /usr/lib/pm-utils/sleep.d/94cpufreq hibernate hibernate: success.
    /usr/lib/pm-utils/sleep.d/95led hibernate hibernate: not applicable.
    /usr/lib/pm-utils/sleep.d/98smart-kernel-video hibernate hibernate: success.
    /usr/lib/pm-utils/sleep.d/99video hibernate hibernate: success.
    Thu Jun 18 11:01:59 EEST 2009: performing hibernate

  • My Superdrive cannot be detected by both my Macbook Pro Retina and MacBook Air. It used to be working perfectly. On the same token My USB stick cant be detected by My MacBook Pro Retina. But It can be detected by my Macbook AIR

    My SuperDrive cannot be detected either by MY MBP Retina and my MBA. it was working perfectly till a month ago.
    To add to this issue my MBP Retina is not able to detect my USB stick either. Is there anything to do with the firmware?!!

    Is this the Apple USB 2.0 SuperDrive (I'm assuming that it has to be...). Likely a problem with the drive, if neither computer recognizes it. Take it to your local Apple Store and have them look it over and see if it will work with any of their display models. If you're still under warranty, they should replace it for nothing. If it's out of warranty, you may just have to buy a new one.
    I would also carry along your rMBP and the USB stick that's causing problems. Have you tried another USB device in the port? Another USB flash drive? Or is the problem with the one flash drive?
    I don't know of any firmware updates for the 2012 models that have come out specifically tied to USB problems. There were some earlier in the year... have you kept up with all of the updates via Software Update?
    Good luck - sounds as if you've a bad SuperDrive and (possibly) a problem with your USB ports (or maybe just this one USB flash drive).
    Clinton

  • OS X kernel logs problem when USB flash drive connected.

    Previously, my Creative Nomad Muvo TX (MP3 player/1GB USB memory stick) worked fine with my Intel Mac mini (10.4.8) until the latest EFI 1.1 update.
    Now the USB drive does not mount or appear in finder. It is visible in the System Profiler in the USB section, but the disk utility does not see it.
    While the USB stick is plugged in, the system logs the following line repeatedly:
    Nov 26 21:32:39 kernel[0]: USBF: 2517.425 AppleUSBEHCI[0x3969000]::Found a transaction past the completion deadline on bus 253, timing out!
    Booting in Windows XP (with bootcamp) and plugging in the USB memory stick works fine. So the USB stick and the Mac mini hardware is functioning.
    Other USB 2 external harddrives are functioning properly in OS X.
    I suspect that the latest Mac OS X or EFI 1.1 firmware update has spoilt my previously happy USB memory stick connection.
    Any suggestions?
    Thanks in adcvance.
    Stephanus

    Hi, Stephanus.
    1. If Creative does not support that device with a Mac, then that should tell you something. Even if it worked in the past, since they don't support it, there's no guarantee that changes to Mac OS X would render it unusable as you've noted. With that kind of attitude from Creative, I'd think about switching to an iPod...
    Since you can use it when booted into Windows with Boot Camp, you might want to consider running Parallels Desktop for Mac. This leverages the virtualization technology of the Intel chips, permitting you to run Mac OS X and Windows simultaneously, rather than having to boot into Windows with Boot Camp. Parallels is cheaper than buying an iPod.
    2. The USB message you reported is essentially indicating that the OS detected a USB device but cannot talk to it. This is unlikely to be something you're going to work around, e.g. with Terminal.
    3. If you want to pursue this further, you can:3.1. Install the USB debug kit for your version of Mac OS X. Apple provides a variety of Mac OS X USB Software Debug Versions that "are used to provide information about USB device and interface detection, driver and interface matching, driver loading and information generated as a result of normal and abnormal conditions." You could install the package corresponding to the version of Mac OS X you are running and this may help identify if the issue is a USB problem and the exact USB anomaly causing such.
    3.2. Take what you've been able to lear from the USB debugger and do one or more of the following:• Join the Apple USB Mailing List. Once your registration is approved, submit a question including the enhanced output from the USB logger and requesting additional advice. That list is monitored by developers of USB devices. Posts are sometimes answered by Apple engineers.
    • Join the Apple Developer Connection at the "free" level, then submit a bug report.
    • Submit a Mac OS X Feedback.If Creative has their own forums, ala Discussions, you might also want to search or post there for similar reports.Unfortunately, that's about all I have to offer at this point: I don't have the Creative device and hence can't test it.
    I think that Creative is disinterested in helping you is a key issue you need to consider.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • My huawei E170 usb stick is not working with the latest mountain lion

    it is able to detect the usb stick. When I tried to install, it tells me that I need Java Runtime 6. I click on install Java 6 and it tell me that pack200 is not working. Tried downloading Java 7, it sitll does not work. search on the community and found the terminal commands to revert back to Java 6. This screwed up my skype and itunes. both application cannot connect to internet. All browsers are still working as well as Parallels 7 with no issue. Tried the terminal command to revert back but it still does not work.

    Reset SMC.  http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".

  • Help needed after "repairing" usb stick -16gb

    Hi there,
    currently have a problem with my Lexar usb stick, approx. 2 years old, 16gb stick. I went for the usual cleaning method of removing files, and checking sizes of folders etc one day, and then decided to check a folder, right clicked and went the usual "get info" ....it started to think...and then ejected the usb stick. Plugged it back in, and did the same thing...same result. So the third time i plugged it back in and decided to do a repair disk in Disk Utilities.
    It ran its course, and then it ejected by itself, thinking it was done its job. okay....so i unplug it from the side of my Macbook Pro...running Snow Leopard...and then plugged it back in...and nothing came up...
    Usually a little light on the usb stick lights up, but nothing happened....tried plugging it in a few times, nothing.
    Tried a variety of PC computers....the only thing i can see is that the disk keeps ejecting itself from the device manager....but i cannot mount it or anything.
    I need help, as there are crucial files on it.
    Also, when I try to do a boot to windows from Mac, when you hold option/alt down, it thinks and keeps thinking but never shows the drive. ....assuming its dead...by why can windows at least see it, just not connect it as a drive.
    Whenever I try running recovery programs it does not find it.
    so again, I cannot do much, but would really like to just put it out there for anyone who has successfully taken care of these problems in the past.
    Thank you for anyone who helps me out.
    much appreciated.
    I've tried running Linux as well, but not too familiar with it...as the usb stick does not even connect there either.

    USB stick is Flash memory you should not delete files often, the only thing you should if you need to free space on it is FORMAT.
    You can try and connect it, Disk Utility should see it. Do erase and use format FAT32.
    If Disk Utility does not see it, try the same on a windows PC; if that does not work either... gone:

  • Installing Solaris Express 11 on a USB stick

    Hi,
    I am in the process of building a resilient development/testing lab server using 4 SATA disks in a RAIDZ configuration, I want to boot the host SE 11 o/s off a internal USB stick to manage this server, so my question is how do I go about installing SE 11 on a USB stick (persistent not a live image).
    Perhaps naively I assumed this would be easy, as Solaris would just see the flash storage as any other storage. What I have attempted is running the live CD, it detected my USB stick and I continued to run through the installer, I choose a "Entire Disk" install, it took an absolute age in doing this, in the process of installing a message/error appeared about the zpool (sorry I should of noted it), but it continued, once complete, I changed the bios option to boot from USB, this resulted in booting what looked like a successful install, but it just sat at the Oracle progress screen about 20 minutes, the one prior to loading the GNOME login page.
    I've googled this to no avail, I'm having a hard time in believing nobody has ever tried this before, perhaps for good reason that I seem to be unaware of.
    Any help would be greatly appreciated.
    Best Regards,
    Jana

    There are varieties of methods and ways, options i.e.
    1.) From Microsoft Windows (NT i.e. XP (5.x), 6 (Vista) & 7) with the "Open Solaris Live USB creator"; this reported works! Easily and quickly with a graphical user interface transferring *.usb and or *.iso files upon flash drives and memory cards bootably, 'select device / drive and file and click start ; from http://devzone.sites.pid0.org/OpenSolaris/opensolaris-liveusb-creator
    2.) With 'usbcopy' under Solaris 11 / Open Solaris and or the 'installgrub' command.; from http://www.milax.org/files/
    For an example, from within (Open) Solaris a command statement (without the quotes) such as;
    In these 'device' is substitute for the actual special device (file) assigned to the usb flash drive, again as an example if it were assigned "c0t2d0s3" and or "/dev/rdsk/c0t2d0s3"; its device "/dev/rdsk/c0t2d0 with two additional, 2 place fields denotating specifics, such as 's3' for a slice or 'p0' the entire flash device for example purpose, partitioning
    #> "fdisk -d /dev/rdsk/'device'" however to partition, and leave space for other partitions
    or
    #> "fdisk -d -B /dev/rdsk/'device'" for a partition using the entire space available;
    then
    #> "dd if=sol-11-exp--live-x86.usb of=/dev/rdsk/'device bs=512" for example to copy the Solaris 'image' to the flash drive
    and then finally, finishing it, installing the grub boot loader, to boot and or 'start' from. i.e. load and initialize (executing) the operating system, would be;
    #> "installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/'device'" would install grub to the 'device' for 'booting', having it startable ; and or plainly "installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0t2d0s3"
    Hopelly helpfull, GOD willing.
    Edited by: Ariel (אריאל) on Jul 21, 2011 1:09 AM
    Edited by: Ariel (אריאל) on Aug 15, 2011 9:00 AM

  • E4200 making my PC beep .... sounds like a USB stick

    I installed a new E4200 just fine.  It works and the wireless components talk to it well.
    My PC is hard wired (ethernet) to it.  And my PC beeps a lot.
    It is the sound of a USB stick being plugged in then ejected.
    This happens if the wireless units (laptop, phone, media player, and iTouch) are on or off.
    Any ideas why?
    Thanks,
    ALG

    Go to 192.168.1.1 and enter in your router's password (default is admin if you haven't changed it), then go to wireless--> guest access, and you should find it. 
    And next time try to be courteous and make a new thread or at least stay on topic if you want to add to someone's thread. 
    I don't work for Cisco. I'm just here to help.

  • Lightroom starting when I plug in a USB stick

    Hi all;
    How can I prevent Lightroom starting when I plug in a USB stick?
    I cannot fins any solution in the Win 7 settings.
    Thanks
    Maarten

    Lightroom preferences (General panel). You'll find an option labeled 'Show import dialog when memory card is detected' . Remove the checkmark.

  • USB 2.0 Stick not detected on USB 3.0 port

    Hey, When I plug in an USB 2.0 Stick into the USB 3.0 port of my T550, it is not detected. USB 3.0 harddisk works. I am working with Windows 10 64 bit.BIOS is updarted to the newest version. Thanks!Nathan

    Hello.  This is Kimberly from the customer experience team at Lenovo. Sorry you are having an issue. The product manager for T Series suggested the following:   We assume that the USB 2.0 drive you are trying to connect functions in another computer.  It is probably a formatting issue or a USB Registry Key Conflict.   If reformatting the USB drive doesn't work, search for USB registry cleaner tools online to remove any conflicts/corrupted USB registry keys.  Also, Microsoft may have some support tools to clean the USB registry keys

  • My old computer can detect my USB when booting, but can't boot Parted

    I have an USB with the Parted Magic Linux environment on it made with Unetbootin, which I tried to boot from other computers and works perfectly.
    However, I have an old computer that can detect the USB in the boot menu (not only in the setup, also in the "Boot from here" menu), but can't boot from it (it just fails as if there wasn't anything bootable in the USB).
    Unfortunately I don't have many more details right now, but does anyone know what is happening?

    Sounds like a hardware issue.
    I just fought with an old "server" box, with two Xeon iii chips in it.  I KNEW that I had good CD's, and I was pretty certain that everything worked, but simply could not get Arch to boot up.
    Finally booted to a diagnostics CD (don't ask which one - it's sorta illegal) and figured out that the CD drive was half-dead, with a lot of IO errors.  Swapped the CD drive, and booted straight into Arch, got it all installed, and on the web.
    Like Gusar says, try a different USB stick, then try a different USB port, or even swap out which USB plug you're using inside the box.  Old machines do some strange things when some odd bit of hardware starts going flaky.
    Last edited by Runaway1956 (2011-12-19 19:10:21)

  • Automatic Start of a script / programm once USB Stick is mounted?

    Is there a way to start a programm each time an USB Stick - in fact any volume - is mounted? In windows that is possible with autorun.inf . Is there something similar with mac?
    All help is appreciated.
    John

    Thanks, that works very well. Although Lignon starts the script everytime anything is mounted I had it to just do the stuff I want by putting another script on the USB Stick that is only available when that stick is inserted. Thus the script I want only runs when I insert the USB Stick.
    Thanks for your help!
    John

Maybe you are looking for

  • XI 3.0 SR1 Install and Config.

    Hello Guru's, I have read the XI 3.0Sr1 installation guide, the only part i didn't quite catch was about the Adapter Engine installation for Business System. Can anyone be kind enough to explain that to me ? I am quite new to this XI concept.. The sc

  • How do I change font size from points into pixels?

    I used to be able to set font size in points but CS 6 has removed this? Please dont say that points = pixels. They do not. See for yourself.  A photoshop doc and an Indesign doc have the same pixel size. A 20 point character "A" in InDesign, will be

  • Update Records with XML

    Hi, I Understand that with XML save you can insert a row into a database however I am very confused about the ability of using XML to update a record. Can I use XML save to update a record? Eg if I have a primary key will it update instead of save? A

  • How to acquire a % Late Task column and produce a visual graph in the report?

    Hi I'm looking for help to help count the number of late tasks within a project and to produce a bar chart of the % of late tasks compared to all tasks. Is this possible? Thanks Rob

  • Recovery Disk Deleted

    Model: HP Pavilion DV6-6077er Product No:LM602EA Serial Nom:5CH11700Q3 Hi.I am from Azerbaijan.My problem this: When I bought the computer Computer had 1 Hard disk.Its memory about 620 GB... I devided it to 2 part...But I did this wrong.Then I didn't