LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-17-2013, 06:12 PM   #1
trunkswar
LQ Newbie
 
Registered: Mar 2013
Posts: 2

Rep: Reputation: Disabled
Mounting hard drive


Hi all I'm new to Linux and been practicing scripting wondering is there a script to mount an external hard drive and cp a file to the external drive then umount the external drive. I've been racking my head on this.
 
Old 03-17-2013, 07:31 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Scripting can be as simple as executing commands sequentially .. you don't really practice scripting so much as automate things you do repeatedly. As you gain experience you'll get the hang of testing return codes, executing commands based on test results .. etc

Code:
mount /dev/sdX /mnt/usb
cp <source> /mnt/usb/
umount /dev/sdX
 
Old 03-17-2013, 07:48 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,521

Rep: Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106
As kbp said, a script is nothing more than a series of commands. Anything you can do on the command line, you can do in a script. It's all about automating normal processes.

How you would write a script to mount a drive, copy a file, and umount the drive is literally no different than if you were doing it on the command line. In fact you could do it on the command line, copy and paste what you typed into an ascii file, give it execute permissions, and boom...you have a script.

Last edited by suicidaleggroll; 03-17-2013 at 07:50 PM.
 
Old 03-17-2013, 08:10 PM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Quote:
Originally Posted by trunkswar View Post
Hi all I'm new to Linux and been practicing scripting wondering is there a script to mount an external hard drive and cp a file to the external drive then umount the external drive. I've been racking my head on this.
sounds a bit like homework to me, but if you post what you have so far, id be more then willing to assist. this is the one type of script ive written several times with several HOWTO's along the way.
 
Old 03-18-2013, 07:53 AM   #5
trunkswar
LQ Newbie
 
Registered: Mar 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks kpb and everyone else
 
  


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 on mounting Hard Disk Drive and CD-ROM drive in Dapper. ussr_1991 Ubuntu 2 08-18-2007 11:33 PM
mounting other hard drive? lilili Linux - General 4 01-06-2006 02:47 PM
mounting a second hard drive BCBruce Linux - Hardware 4 12-19-2005 09:51 AM
Need help mounting a hard drive cevilgenius Linux - Newbie 15 04-12-2005 02:35 PM
mounting a second hard drive evilRhino Linux - General 2 10-17-2002 01:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:32 AM.

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