LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-02-2004, 12:01 AM   #1
bdika
Member
 
Registered: Aug 2003
Location: London, Canada
Distribution: Ubuntu Breezy Badger
Posts: 60

Rep: Reputation: 15
Changing to root from within a script


Hi

I am trying to write a script that will allow me to mount my Sony Clie memory stick by clicking on a desktop icon. I am using Mandrake 9.2 and KDE. When I enter the following in a command line it works but in a shell script it doesn't. Here are the commands:

su <enter>
myrootpassword <enter>
mount -t vfat /dev/sda1 /mnt/ClieMS <enter>
cd /mnt/ClieMS <enter>

When I go through the above sequence I can then work with the files on my memory stick fine on the command line. Although when I click on the /mnt/ClieMS directory the Konqueror file browser gives me an "Acces denied" error message. I chmod 777 /mnt/ClieMS but it doesn't help.

Second problem:

How do I change to root from within a script without having the script stop execution for me to enter the root password. That is, is there a way of writing my password into the script so that it processes my root password automatically. Here is what I tried but it stops execution for me to enter my password and then seems to exit. That is it doesn't change directories.

#!/bin/bash
su
myrootpassword
mount -t vfat /dev/sda1 /mnt/ClieMS
cd /mnt/ClieMS

P.S. It won't let me mount the memory stick without being root.

Any help on either of these problems would be greatly appreciated.

Regards,
Bill Dika
 
Old 01-02-2004, 12:07 AM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 59
well i see what your getting at, but your getting ahead of yourself, and you don't need to do what you are trying to do...
just make an entry in your fstab, to allow regular users to use this mount,
i'll show an example of an entry in my fstab for one of my drives, that allows all users to have access
Code:
/dev/hdf1               /mnt/R2                 ext3    user,rw,exec,uid=500            0 0
the part in bold is the point i am trying to get across...
so find your sda1 device in your fstab and change the options accordingly...
note:
i personally use the uid=500 because that is the userID of my regular user, and i don't use any other users so thats how i defined it...
alot of people use the option umask=000 instead, so its up to you..
 
Old 01-02-2004, 12:23 AM   #3
bdika
Member
 
Registered: Aug 2003
Location: London, Canada
Distribution: Ubuntu Breezy Badger
Posts: 60

Original Poster
Rep: Reputation: 15
Thanks Dr Ozz but unless I'm mistaken I don't think that I can put it into fstab file because the Sony Clie has to be in the connection cradle and activated before the mount command is issued or the mount command will fail. Its a usb connection.

Is my thinking correct here or should I be trying that anyway.

Many thanks.

Regards,
Bill Dika
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help changing backup script phatboyz Programming 4 06-11-2005 01:36 PM
changing to root laxboy130126 Programming 2 02-26-2005 09:09 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM
changing to root sooraj_pathe Linux - General 1 03-11-2004 11:52 AM
Changing root@localhost to root@domain.com Stingreen Linux - General 14 12-17-2002 07:21 PM


All times are GMT -5. The time now is 02:09 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration