LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-01-2009, 12:03 PM   #1
h725
Member
 
Registered: Apr 2008
Posts: 114

Rep: Reputation: 15
Problem with udev and custom script


Hi all,

I wrote a simple udev rule:

ATTRS{vendor}=="Generic ", ATTRS{model}=="USB Flash Disk ", NAME="usb%n", RUN+="/root/usbmount.sh"

# cat /root/usbmount.sh

#!/bin/bash
export DISPLAY=:0.0
mount -t vfat -o rw,uid=1000,sync /dev/usb1 /mnt/usb
cd /mnt/usb
sudo -u h725 -H aterm



..when I insert the usb stick, /dev/usb1 is created, aterm starts but WITHOUT /mnt/usb mounted!
I need to exit aterm (ctrl-d), and aterm respawn itself, this time with /mnt/usb mounted.

Why this strange behavior? Why aterm starts twice?


This is my /var/log/messages:

Jan 1 18:56:56 s1 sudo: root : TTY=unknown ; PWD=/mnt/usb ; USER=h725 ; COMMAND=/usr/bin/aterm
Jan 1 18:56:56 s1 sudo: pam_unix(sudo:session): session opened for user h725 by (uid=0)
Jan 1 18:56:56 s1 sudo: pam_unix(sudo:session): session closed for user h725
Jan 1 18:58:52 s1 sudo: root : TTY=unknown ; PWD=/mnt/usb ; USER=h725 ; COMMAND=/usr/bin/aterm
Jan 1 18:58:52 s1 sudo: pam_unix(sudo:session): session opened for user h725 by (uid=0)
Jan 1 18:58:52 s1 sudo: pam_unix(sudo:session): session closed for user h725
 
Old 01-01-2009, 12:56 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Perhaps it's going to fast and the aterm is entering the folder before the mount command is completed. Try putting a "sleep 1" or so between the mount command and the cd.

Another option, if you can't get this to work, is to use ivman instead. It detects hal events such as the appearance of new hardware or changes in mount condition, and it can be set to first mount a drive and then separately launch a command or script once it's mounted.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Location for Custom udev Rules Toods Slackware 7 11-19-2007 12:42 PM
SELinux problem with a custom script at startup caps_phisto Linux - Security 1 06-23-2007 12:37 PM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 03:43 AM
Wrong group with custom udev rule enragedchip Linux - Hardware 1 12-11-2005 02:46 PM
Gentoo custom script dependancy problem exodist Linux - Distributions 18 07-24-2004 01:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration