Go Back   Android Forums > Android Community > The Lounge > Computers & IT

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

Like Tree4Likes
  • 1 Post By MoodyBlues
  • 1 Post By MoodyBlues
  • 1 Post By palmtree5
  • 1 Post By saptech

test: Reply
 
LinkBack Thread Tools
Old October 22nd, 2013, 11:21 PM   #1 (permalink)
I ain't nobody!
Thread Author (OP)
 
saptech's Avatar
 
Join Date: Dec 2011
Location: Third Stone from the Sun
Posts: 3,538
 
Device(s): Motorola Moto G, Samsung Stratosphere, Galaxy Tab 2 SE.
Carrier: T-Mobile

Thanks: 571
Thanked 768 Times in 612 Posts
Default Check Device with Script File

Is there a way for a script file to check if the usb hard drive is connected and if it is, continue, if not, pause with message asking user to check the connection or power?

How would I go about having the script check for the device?

Thnx.

__________________
Like it is...Yusef Lateef
saptech is online now  
Reply With Quote
sponsored links
Old October 23rd, 2013, 12:12 AM   #2 (permalink)
- Crazy peacock person -
 
MoodyBlues's Avatar
 
Join Date: Jan 2011
Location: echo $HOME; California
Posts: 2,778
 
Device(s): Kindle Fire HD 8.9" (rooted), Motorola Atrix 2, Motorola Atrix 4G (retired), Motorola Bravo (retired
Carrier: AT&T

Thanks: 925
Thanked 1,361 Times in 822 Posts
Default

A few details would go a long way, my friend!
saptech likes this.
__________________
Info on Heartbleed bug; updated with helpful links


MoodyBlues is offline  
Reply With Quote
Old October 23rd, 2013, 02:52 AM   #3 (permalink)
I ain't nobody!
Thread Author (OP)
 
saptech's Avatar
 
Join Date: Dec 2011
Location: Third Stone from the Sun
Posts: 3,538
 
Device(s): Motorola Moto G, Samsung Stratosphere, Galaxy Tab 2 SE.
Carrier: T-Mobile

Thanks: 571
Thanked 768 Times in 612 Posts
Default

Well, I'm wanting to write a script to do a backup of my system. I'm backing up to an external hard drive. This is what I have so far. Keep in mind, I'm not any good at writing scripts.

Quote:
while true
do
# (1) prompt user, and read command line argument
read -p "Is this a Backup, Restore or Cancel:? " answer

# (2) handle the input we were given
case $answer in
[bB]* ) fsarchiver backup command goes here
echo "Okay, Backup is done!."
break;;

else
case $answer in
[rR]* ) fsarchiver restore command goes here
echo "Okay, Restore is done!."
break;;

[cC]* ) exit;;

* ) echo "Dude, just enter B, R or C, please.";;
esac
done
saptech is online now  
Reply With Quote
Old October 23rd, 2013, 03:21 PM   #4 (permalink)
- Crazy peacock person -
 
MoodyBlues's Avatar
 
Join Date: Jan 2011
Location: echo $HOME; California
Posts: 2,778
 
Device(s): Kindle Fire HD 8.9" (rooted), Motorola Atrix 2, Motorola Atrix 4G (retired), Motorola Bravo (retired
Carrier: AT&T

Thanks: 925
Thanked 1,361 Times in 822 Posts
Default

EVERYTHING is possible with *nix, so, yes, it's possible to check for the drive's existence before proceeding. However, I'm so far out of the loop that I have no idea [right now] how to check for a USB drive's presence. I mean elegantly. There's an easy workaround, which is to simply place a file on it and then check for its existence.

If someone else doesn't pop in with a way to do it elegantly, I'll do some experimenting and see what I can come up with.
saptech likes this.
MoodyBlues is offline  
Reply With Quote
Old October 23rd, 2013, 05:05 PM   #5 (permalink)
Senior Member
 
palmtree5's Avatar
 
Join Date: May 2012
Location: USA
Gender: Male
Posts: 2,741
 
Device(s): HTC One SV, Samsung Galaxy Prevail (retired), Nexus 7 (Gen 1)
Carrier: Boost Mobile

Thanks: 1,655
Thanked 1,458 Times in 752 Posts
Default

Here's a start (assuming that you will always back up to the same disk)

Code:
ls /dev/disk/by-uuid/$UUID | tail -c +19
where $UUID is the uuid of the drive you are using. The result of the tail command could then be piped to another command.
saptech likes this.
__________________
Find a post helpful? Hit
See spam or something offensive? Hit
New to the site? Site Rules/Guidelines and Introductions
Not a member yet but want to join? Join here!
Let's cure cancer with our phones
palmtree5 is online now  
Reply With Quote
The Following 2 Users Say Thank You to palmtree5 For This Useful Post:
MoodyBlues (October 23rd, 2013), saptech (October 23rd, 2013)
Old October 23rd, 2013, 09:58 PM   #6 (permalink)
I ain't nobody!
Thread Author (OP)
 
saptech's Avatar
 
Join Date: Dec 2011
Location: Third Stone from the Sun
Posts: 3,538
 
Device(s): Motorola Moto G, Samsung Stratosphere, Galaxy Tab 2 SE.
Carrier: T-Mobile

Thanks: 571
Thanked 768 Times in 612 Posts
Default

Thanks for that. I'll keep these ideas in mind. Yes for now anyway, it will be the same ext. hd. And using an existing file on the ddrive is a good ideal also, Moody.

I'm just playing around with writing simple scripts to get better familar with them. I will work on it during the weekends.

Thnx. again.
MoodyBlues likes this.
saptech is online now  
Reply With Quote
Reply


Go Back   Android Forums > Android Community > The Lounge > Computers & IT
Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:15 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.