[Solved] Want a script file to copy 6 files to c:\daily-files\

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
mikecolley
Level 3
Level 3
Posts: 118
Joined: Fri May 20, 2011 5:41 am

[Solved] Want a script file to copy 6 files to c:\daily-files\

Post by mikecolley »

Hi all:

I boot and run mint 17 cinnamon off of a flash thumb drive all of the time. Sometimes I plug the flash drive into a different computer and boot to the flash drive there. 99.99% of my time is in this mint 17 cinnamon flash thumb drive. I use the c:\ drive on the computer as a backup for six files and I just don't use windows vista/7/10 for much of anything else. I boot into mint 17 directly at power up using the flash thumb drive and use the flash thumb drive for essentially everything, but sometimes I boot to it on a different computer, so the flash drive always almost always stays the same, but the computer (and drive c:) can change depending on which computer I am on. Sometimes I use an exact image of the flash drive to boot linux mint 17 on a different flash thumb drive. So, the serial number of the flash drive can change and the serial number of the hard drive can change.

I have been using Nemo to copy fhe six files but I would appreciate having a script file to copy the files to c:\daily-files\ on whatever computer or flash drive I am using.

How can I write a script file to copy six linux (mint 17 libreoffice) spreadsheets to c:\daily-files\ on whatever windows computer I plug the flash drive into???

A solution format could be either exact directions or a pointer to a "how-to", either would work for me. I'm just having trouble finding the correct how-to in order to write the script file.

system:
Computer: Elitebook 8730w (yep, it is old and could be any of Vista/7/10)
Mint version: Linux mint 17.0 cinnamon
Boot and production disk: Sandisk Ultra USB 3.0 256GB flash thumb drive (TMI: two partitions, first is a small linux live boot to the big linux mint 17 partition)

Thank You Clem and All - Mike
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
WharfRat

Re: Want a script file to copy 6 files to c:\daily-files\

Post by WharfRat »

I'll give you a general outline.

Mount the windows partition from /etc/rc.local after a 15 second or so delay.

Have a small script to run rsync from /etc/rc.local

rsync will sync the files that have changed on the source so there might be only one or two files that would need to be copied.
mikecolley
Level 3
Level 3
Posts: 118
Joined: Fri May 20, 2011 5:41 am

Re: Want a script file to copy 6 files to c:\daily-files\

Post by mikecolley »

Thank You kind sir Mr. WharfRat

I like your directions, they are better than what I was planning of doing with cp.

Next layer of pealing this onion to find the correct question for me to ask: What is the best way to mount the local win hard drive c: in mint 17?

Chuckle about my inadequacy, with the graphical interface in mint 17 making everything so easy, I forgot I had to mount c: . The mint graphical interface makes it so easy, I forgot about the need to mount. My brain is atrophying.

I never paid attention how to find c: in linux and then mount it so now I will have to re-learn that from many years ago. I've even lost the books. Some of these computers I use have multiple partitions on the hard drive (for the purpose of machine diagnostics or as windows restore) and I'm lost about how to find the correct hard drive partition and then mount it. Can you give me a pointer on the correct way to do that? No, --- wait ---, that question requires a complicated solution.

On second thought, it will probably be easier to just write the script for only one machine and hardcode c: in the script because I use just one machine 95% of the time, I think my question for many machines involves too many variables. Probably a better question for me to ask, that has an easier solution, is, how can I mount c: using just one machine, one hard drive that has several partitions on the hard drive. That would be a better question for me to ask because the answer would be shorter (but I wouldn't turn down the multiple machine solution).

Thank You! - Mike
WharfRat

Re: Want a script file to copy 6 files to c:\daily-files\

Post by WharfRat »

In linux there is no such thing as C: or D:

The partition will be /dev/sda? where the ? is 1,2,3 etc.

Use blkid to locate it e.g.,

Code: Select all

bill@XPS] ~ $ blkid
/dev/sda1: UUID="B76E-EC37" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="f4dd4936-ce86-479a-ba30-e77235d939a7"
/dev/sda2: LABEL="serena" UUID="8f8906a7-1632-4e15-9a00-b17e7a875aab" TYPE="ext4" PARTUUID="07136d97-bb08-433e-8aa9-74823c72225e"
/dev/sda3: UUID="b1e377ee-ee7f-4953-998b-81f92f913143" TYPE="swap" PARTUUID="d759f667-0322-4852-8699-7781d03ce00b"
I don't have a windows installation here, but the the type will be TYPE="ntfs"

You can grep ntfs with blkid|grep ntfs

To strip down to the device to be used to mount it from a script you can use blkid|grep ntfs|awk '{print $1}'|tr -d :

Create a mountpoint /media/win on your two computers and use

mount -t ntfs-3g -o defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000 $(blkid|grep ntfs|awk '{print $1}'|tr -d :) /media/win

Good luck :wink:
mikecolley
Level 3
Level 3
Posts: 118
Joined: Fri May 20, 2011 5:41 am

Re: Want a script file to copy 6 files to c:\daily-files\

Post by mikecolley »

Thank You Mr. WharfRat!

Of course you are right that there is no c: in linux, I'm very happy about that. I was only using "c:" as a metaphor to represent the main windows drive in linux even though I was approaching this in linux that has no "c:".

I will try to get to this solution later tomorrow. I really like your solution, now I just have to get it to work. That solution is something I never would have come up with myself, BIG Thank You.

Is the following correct??? This is a question: If I don't re-boot and I run this script file from the command line on several separate days to copy the spreadsheets, or if I accidentally mount this ntfs partition using Nemo, I would guess I should first and also last perform umount

Code: Select all

# this is a question, not an answer
# should I use the following four umounts?

umount /media/win
umount /dev/sda1

# mount instructions go here

# copy instructions go here

umount /media/win
umount /dev/sda1

both at the beginning and at the end of the script file I use to copy the spreadsheet files. Is using the four umounts a good idea(possibly required)?

BIG Thanks! - Mike
WharfRat

Re: Want a script file to copy 6 files to c:\daily-files\

Post by WharfRat »

The problem mounting with Nemo is it will use the mountpoint of /media/yourname/UUID so you can't assume /media/win will be mounted.

In addition I think that the label name will be used instead of the UUID if the partition label is set.

Also a ntfs partition cannot be mounted twice so yes you will have to unmount from /media/yourname/UUID first before attempting to mount it to /media/win

And to unmount the partition at the end of the script, you need only reference the device /dev/sda1 or /media/win/

So either umount /dev/sda1 OR umount /media/win will unmount the partition.
mikecolley
Level 3
Level 3
Posts: 118
Joined: Fri May 20, 2011 5:41 am

[Solved] Re: Want a script file to copy 6 files to c:\daily-files\

Post by mikecolley »

Thank You very kindly Mr. WharfRat

It worked. IT WORKED!!! At least one time from the command line, it worked!

I had to use sudo in front of "blkid..."

I had to use sudo in front of "mount..." but the windows files appeared in /media/win/ (I suspect the different linux and windows user name required sudo)

I cp from the command line and it worked.

I had to use sudo in front of cp (will change cp to rsync) because the user on the hard drive /media/win/daily-files (c:\daily-files) is different from the linux user.

It worked. IT WORKED!!!

I am changing this subject to Solved. My next project is to put all this stuff into a script file that works.

Thank You very kindly Mr. WharfRat

Thank You - Mike
Locked

Return to “Software & Applications”