Active Topics

 


Reply
Thread Tools
Posts: 144 | Thanked: 68 times | Joined on Mar 2011 @ a spot
#1
hey all,
I need to make a script which checks if the memory card is plugged in my N900, i.e. is mounted. It goes like...
if [ code to see if mmc card plugged in ]; then...

Yes, I am still at the learning phase and I tried searching lots of forums and other websites but no go, please HELP! the poor.

Last edited by GigaByte; 2011-09-06 at 11:05.
 
Posts: 144 | Thanked: 68 times | Joined on Mar 2011 @ a spot
#2
Bump.
I just want to know the command that checks if the mmc is plugged in or not
 
Banned | Posts: 3,412 | Thanked: 1,043 times | Joined on Feb 2010
#3
Sorry to see nobody answer you but you do not need a script to see if your SD card is plugged in or not because it is already built in to the OS.

Are you having problems seeing the sd card?.
 
Banned | Posts: 3,412 | Thanked: 1,043 times | Joined on Feb 2010
#4
You use the browser in your device to see it is there or not also you can use your pc browser to see it and write or mount whatever you want.

You need to be more specific to what problem your having.
 
Posts: 28 | Thanked: 10 times | Joined on Dec 2010 @ near Paris
#5
hi ithink this should help
$ mount | grep mmc1 | wc -l
if result>=1 , u r done
 

The Following User Says Thank You to stef For This Useful Post:
Posts: 144 | Thanked: 68 times | Joined on Mar 2011 @ a spot
#6
Originally Posted by abill_uk View Post
You use the browser in your device to see it is there or not also you can use your pc browser to see it and write or mount whatever you want.

You need to be more specific to what problem your having.
Yeah well. It's not like that.

I want to make script that does "something" when the sd card is plugged in, and another "thing" when it isn't plugged in.
For that to work, I need to implement a code in the script that checks if the memory card is in or not, to see what "thing" it shall do.
 
Posts: 144 | Thanked: 68 times | Joined on Mar 2011 @ a spot
#7
Originally Posted by stef View Post
hi ithink this should help
$ mount | grep mmc1 | wc -l
if result>=1 , u r done
Thanks stef, will try that right now and report.
 
Posts: 167 | Thanked: 204 times | Joined on Jul 2010
#8
The list of what's mounted is /etc/mtab, and the mmc is /dev/mmcblk1p1.

So something like

Code:
TEST=`grep -o mmcblk1p1 /etc/mtab`;
if [ ! -z "$TEST" ]; then
# do something
else
# don't do something
fi
Edited to explain:

First line sets the variable $TEST with the output of the command that's in backticks. The grep command searches for the mmcblk1p1 in the list of what's currently mounted, the -o switch says output only what matched.

Then, in shell, if that gets us a non zero length response, well, we found what we were grepping for, if not we didn't...

Last edited by magick777; 2011-09-06 at 12:17. Reason: Explanation, missing bracket
 

The Following User Says Thank You to magick777 For This Useful Post:
Posts: 144 | Thanked: 68 times | Joined on Mar 2011 @ a spot
#9
Originally Posted by stef View Post
hi ithink this should help
$ mount | grep mmc1 | wc -l
if result>=1 , u r done
Wow worked like a treat! thanks!
 
Posts: 144 | Thanked: 68 times | Joined on Mar 2011 @ a spot
#10
Originally Posted by magick777 View Post
The list of what's mounted is /etc/mtab, and the mmc is /dev/mmcblk1p1.

So something like

Code:
TEST=`grep -o mmcblk1p1 /etc/mtab`;
if [ ! -z "$TEST"; then
# do something
else
# don't do something
fi
Edited to explain:

First line sets the variable $TEST with the output of the command that's in backticks. The grep command searches for the mmcblk1p1 in the list of what's currently mounted, the -o switch says output only what matched.

Then, in shell, if that gets us a non zero length response, well, we found what we were grepping for, if not we didn't...
This also worked great, huge thanks man.

p.s. You forgot a ] but never mind, got everything sorted now thanks
 
Reply


 
Forum Jump


All times are GMT. The time now is 00:36.