You are not logged in.
Pages: 1
I feel like an idiot for posting something so basic here, but I want to write a small bash script.
Basically, I want it to--when I plug in my MicroSD card that I use for my NDS into my laptop--copy all the ROM save files on that disk into a remote folder for backup.
It'd be something like:
cp -r /media/vdisk/*.sav /my/backup/folder
But, I can't figure out any way to make it run automatically in the background whenever I put the card in. Advice?
(Also, to the mods, I wasn't sure where to put this, sorry. )
Offline
You could have a background process watch /media/vdisk/ to see if it's mounted, and if so, do what you described.
#!/bin/bash
while true; do
if mountpoint -q /media/vdisk; then
# do stuff
fi
sleep 3 # keep it from eating CPU
done
Should work, though I haven't tested it.
There's probably a more elegant solution involving hal, but meh.
Last edited by Peasantoid (2009-10-29 00:47:54)
Offline
the "best" solution IMHO would be to have an udev rule which executes a mount & copy script on card insertion. A good starting point for writing udev rules can be found here
My System: Dell XPS 13 | i7-7560U | 16GB RAM | 512GB SSD | FHD Screen | Arch Linux
My Workstation/Server: Supermicro X11SSZ-F | Xeon E3-1245 v6 | 64GB RAM | 1TB SSD Raid 1 + 6TB HDD ZFS Raid Z1 | Proxmox VE
My Stuff at Github: github
My Homepage: Seiichiros HP
Offline
Pages: 1