LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   script (https://www.linuxquestions.org/questions/linux-software-2/script-80351/)

bmike1 08-09-2003 12:56 AM

script
 
On my desk top are a couple of icons. One is for reading the contents of the floppy drive while the other does the cdrom drive. Well, it mounts them nicely yet it does not unmount them. How would one write a script which when invoked would unmount the cdrom or the floppy?
PS~ I plan on creating a link to these files on the desktop.

My idea is that I would open my favorite editor (jpico) and:

# file to unmount (floppy/cdrom)
umount /mnt/floppy
end

Unfortunately, that is to simple to be right. What is the right method?

DrOzz 08-09-2003 01:10 AM

actually am i not correct when i say you can right click the icon on your desktop and go to "eject" or "unmount" or whatever it says??
i dont' know what distro your using so this may not be the case in your scenerio.

or you can just write an alias in your .bashrc file and if you are actually not up for typing umount /mnt/floppy then you can add something like this to your .bashrc :
alias uf='umount /mnt/floppy'

where when you type "uf" in the terminal it will unmount it

or you can just open up a blank file with pico or whatever your using and just type:
umount /mnt/floppy
and then :
chmod 777 filename
and then just run :
./filename
whenever you want to unmount and you can also create a desktop link to that file

so theres a couple of options for ya

bmike1 08-09-2003 01:57 AM

Howdy Doc! Well, since posting my original question I have learned that I was wrong; the desktop shortcuts do not mount the floppy or cdrom. So i modified your instructions to say:
#mountfloppy
mount /mnt/floppy
Unfortunately it did not work. Infact, the icon for the file shows it to be merely a text file. So what do I do now?

acid_kewpie 08-09-2003 02:55 AM

set the file to be executable via chmod and add a line at the top saying [code]#!/bin/bash{/code]

bmike1 08-09-2003 03:52 PM

Ok ,
After I added Kewpie's line the text page icon turned into a <?> executable file <?> (it is a page with a green arrow on it). But when I click on that icon the 'open with' box appears. I tried opening it with an editor but all that did was open the text editor with the lines in it. What should I open it with? One thing further: if I open a terminal and mount the floppy and then clic the floppy icon it takes around 2 minutes and forty seconds for the floppy GUI window to appear with all the icons in it. Is there any way to speed that up?
Following are the lines for the two files I created.
#mountcdrom
[code]#!/bin/bash{/code]
mount /mnt/cdrom
&
#mountfloppy
[code]#!/bin/bash[/code}
mount /mnt/floppy

DrOzz 08-09-2003 04:28 PM

what distro are you using?
for the simplicity of this command a simple :
mount /mnt/floppy in an empty file and saving it and then chmod'ing it to being executable will suffice...
anyways it was a misprint in acids post, and you don't type them code tags as he was implying it to look like this:
Code:

#!/bin/bash

bmike1 08-09-2003 08:24 PM

Sorry I haven't told you the distro I am using yet; it is Debian. As for the misprint in Acid's post it was done so it wouldn't be read as html tags.
Post # 5 has included within it exactly (except the } & { are reaally a] & [) what I have written in said files. Are they incorrect? How so?


All times are GMT -5. The time now is 03:12 AM.