Register
It is currently Thu Oct 02, 2014 8:28 am

Script for copying files to floppy drive.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Sun Apr 15, 2007 2:26 pm   

Joined: Sun Apr 15, 2007 1:49 pm
Posts: 3
Hello:

My OpenOffice word processor does not copy files I am working on to the floppy drive very well. To say the least! At first it took me 3 minutes to copy a small file, with the floppy drive labouring noisily all the while. I've got the process down to 19 seconds on a faster machine and with K formatted floppies with an ext2 filesystem.

I have already created a script that will ask for a filename and then copy the named file to the floppy drive.
I, of course, run this script on the Konsole shell, not inside my OpenOffice file.

Here it is:

#This bash script copies a file to the floppy drive.
#!/bin/bash


echo "Enter the name of your file, and press ENTER: "

read FILENAME

cp /home/johsmi/$FILENAME /media/floppy

echo "Your file $FILENAME has been successfully copied to the floppy drive."

I would like the option of being able to just press ENTER for the second, third and subsequent copying of the same file. (I'm writing a book and want to save complicated changes as I go.)

Because of peculiarities connected with exporting of variables to the environment, I haven't yet managed to export a variable then test at the beginning of the script to see whether the variable already contains a value or not.

I am a complete newbie, so simplicity is of the essence.

Any help will be appreciated. :o


Top
 Profile  
 PostPosted: Mon May 07, 2007 4:11 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Hi harrier!

So what you want to do is have the script, instead of exiting after it copies the file, wait for you to hit enter so that it can copy it again? There's a couple of ways to do this, here's one using an "until" loop (I love "until" :)

Quote:
#!/bin/bash
#This bash script copies a file to the floppy drive.


echo -n "Enter the name of your file, and press ENTER: "
read input

until [ "$choice" = q ]; do

cp /home/joe/$input /tmp/$input

echo "Your file $input has been successfully copied to the floppy drive."
echo "Would you like to back up $input again?"
echo -n "Press ENTER for yes, or "q" to quit: "
read -n1 choice
echo

done



Another thing you might want to consider is using a while loop to auto-save at designated intervals (every 5 minutes or so). If you go that route you may want to keep a couple of backups (filename_1, filename_2, filename_3, etc...) in case something goes wrong.

Hope this helps! (even if it is 2 weeks late)


Top
 Profile YIM  
 PostPosted: Sat May 12, 2007 1:12 pm   

Joined: Sun Apr 15, 2007 1:49 pm
Posts: 3
Hi, JEO:

I hope this message is posted properly so you will find it.

The script you provided me with was worth more than a hundred pages of geekspeak. It also worked.

I was surprised that I could go from the inside of this little program to the Alt-tab screen to inside an OpenOffice document, throwing in the odd ENTER here or there, and then back to your script in the shell, without causing anything to malfunction. (just as you can go from any other program in memory, e.g. OpenOffice, to another, e.g. Mozilla).

It was quite wonderful. I only discovered something a bit off when I did a "Save As" inside OpenOffice. A bit of gibberish got placed inside the location screen. Whether there was any connection, I don't yet know. It didn't seem to happen a second time.

Anyways that was a wonderful lesson.

I was thinking that if I knew OpenOffice VBA (Visual Basic for Applications), this could simplify the whole thing even more. However, I now do seem to have a way of doing easy backups to floppy. My God, if this message reaches you, I've even learned how to use a forum.

A tip of the hat from Harrier. :)


Top
 Profile  
 PostPosted: Sat May 12, 2007 8:06 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Any time sir! Glad it worked for ya :)


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP