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.

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 choiceecho

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.

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.

Who is online

Users browsing this forum: Bing [Bot] and 22 guests

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