User Tools

Site Tools


keckcaves:transferring_data_remotely

Transferring Data Remotely

To gain access to a computer remotely see Remote Access. Once you are familiar with gaining remote access you might want to transfer information/data back and forth from one computer to another. To do so, you can use the following commands for these basic tasks:

Below is a tutorial on how one can use ssh and scp to locate and copy files from one computer to another remotely.

Tools like the VNC tool (Using VruiVNC) and snapshot tool (Virtual Still Camera) allow uses to send data while working in the CAVE to external locations. Often times I use a spreadsheet on Cavemac in conjunction with the VNC tool. The snapshot tool send images captured in the CAVE to the directory* in which you have started the CAVE from on Caveman. Most often this is your home directory.

After working in the CAVE I like to work with the data I collected from my own computer. To do this I need to access Caveman and Cavemac, locate were the data is that I need, and then copy it to my personal computer. You can find a list of basic Unix commands here Some basic Unix commands, but we will also cover a few of them durning this tutorial.

Remote access with ssh: locating a file and a path

To to copy my spreadsheet from Cavemac to my personal computer I am going to first locate where the files are that I want to copy to my personal computer.

  • Start by opening a Terminal window

Next we need to connect to Cavemac using ssh and locate our spreadsheet.

  • Type in ‘ssh’ and then the ‘hostname’ you are wishing to connect to
ssh username@cavemac.geology.ucdavis.edu

Once you are connected you will be in your home directory.

cavemac:~ username$

Next you will want to find the full path* of where your spreadsheet is located. Most often I store spreadsheets I use in a folder titled “spreadsheets” in the directory called “Desktop”. First we will want to see where it is we are currently located and where it is we want to go. To see your current location we use the terminal command 'pwd', which shows the location of your current directory.

  • In your terminal window type 'pwd'
cavemac:~ username$ pwd

/Users/username

'/Users/username' is the full path from your root directory to your current location. In order to see what is in you current directory we can now use the ' ls' terminal command.

  • In your terminal window type 'ls'
cavemac:~ username$ ls

Desktop		Movies			Sites
Documents	Music			
Downloads	Pictures			
Library		Public

This is a list of the directories and files that are located in your current directory. We know that the spreadsheet we are looking for is in a file folder (directory) called “spreadsheets” that is located in the directory called “Desktop”. The list above shows the directory called “Desktop” and now we need to change to that directory. The terminal command to do this is ' cd'. 'cd' stands for change directory.

  • In your terminal window type 'cd' and then the name of the directory you want to change to.
cavemac:~ username$ cd Desktop

cavemac:Desktop username$

Now if you use the 'ls' terminal command you will get a list of the directories and files in your current directory which is called “Desktop”.

cavemac:Desktop username$ ls

cave work.txt
spreadsheets
stuff

We can now see the directory we want which is called 'spreadsheets'. In order to change to it we will again use the terminal command 'cd'.

  • In your terminal window type 'cd' and then 'spreadsheets'.
cavemac:Desktop username$ cd spreadsheets

cavemac:spreadsheets username$

We are now in the directory spreadsheets and if we use the 'ls' terminal command we will see our spreadsheet called “microbailite_data”. We can also use the terminal command 'pwd' to find the full path name of our current location.

  • In your terminal window type 'ls'
cavemac:spreadsheets username$ ls

microbailte_data.xlsx
work.xlsx
  • In your terminal window type 'pwd'
cavemac:spreadsheets username$ pwd

/Users/username/Desktop/spreadsheets

We have now located the file “microbailte_data.xlsx” and the path of it's location on Cavemac. Both the file name and the path of where it is located on Cavemac will be needed to transfer the file remotely using 'scp' to your personal computer.

Copying a file using scp

Using the 'scp' protocol to securely copy files from the remotely accessed computer to your local one (your personal computer) can be fairly straight forward. Using the guidelines from the above tutorial “Remote access with ssh: locating a file and a path” we have already located the file we intend to remotely copy (microbailte_data.xlsx) and the full path of that files location (/Users/username/Desktop/spreadsheets).

We are now going to copy the file 'microbailte_data.xlsx' from cavemac to our personal computer remotely using 'scp'.

  • To start open a new terminal command window

When using 'scp' you want to start by stating what is that you want (the path and the file name) and then where it is you want to put it. What we want is the file 'microbailte_data.xlsx' from Cavemac and we want to put it in a directory which is located on my personal called 'CavesWork'. There are several ways to do this, I will take you through two of them.

  • In the new terminal command window type 'scp' then the location of the file you want followed by where you want to put it.
personalcomputer:~ username$ scp username@cavemac.geology.ucdavis.edu:/Users/username/Desktop/spreadsheets/microbailte_data.xlsx /Users/username/Desktop/CaveWork

As a review we copied the file 'microbialite_data.xlsx' located on Cavemac ('username@Cavemac.geology.ucdavis.edu:/Users/username/Desktop/spreadsheets/microbailte_data.xlsx', the : separates the path from the hostname and then we add a space and the location of were we want to copy the file to '/Users/username/Desktop/CaveWork') to our personal computer.

The file 'microbailte_data.xlsx' has now been copied to the directory 'CaveWork' on my personal computer. If I want to check to make sure it is there we can use the terminal commands 'cd' and 'ls' to do so

  • In the same terminal command window type 'cd' and the path to 'CaveWork'. Next type the terminal command 'ls' to locate your copied file.
personalcomputer:~ username$ cd Desktop/CaveWork

personalcomputer:CaveWork username$ ls

Data.xlsx
microbailte_data.xlsx

Another another way of doing this is to change your current directory to the location you wish to put the file and then use '.' as the path location in your command line instead of typing the path of where you would like to copy the file to. The command '.' means current directory.

  • The steps are very similar as stated above, however first you will need to change to the directory you wish to put your file in.
personalcomputer:~ username$ cd Desktop/CaveWork

personalcomputer:CaveWork username$ scp username@cavemac.geology.ucdavis.edu:/Users/username/Desktop/spreadsheets/microbailte_data.xlsx .

This does the exact same thing as the first way, it just uses the terminal command '.' instead of typing out the entire path.

Now say you have altered your 'microbailte_data.xlsx', renamed it as 'microbailte_data2.xlsx', and want to put the new version back on Cavemac in the directory 'spreadsheets'. To do this it is the same steps as above, state what you want and then where you want to put it.

personalcomputer:~ username$ scp ~/Desktop/CaveWork/microbailte_data2.xlsx username@cavemac.geology.ucdavis.edu:/Users/username/Desktop/spreadsheets

As a review we stated what file we wanted “microbailte_data2.xlsx” and where it is located. This time we used '~', which works as indicating your 'home directory' instead of typing the path starting from the root directory. Then we stated where we wanted to put it.

Copying multiple files at once using scp

I just have copied my spreadsheet to my personal computer and I now want to copy the snapshots I took using the snapshot tool from Caveman to my personal computer. I am going to want to make a new directory called “CaveImages” located in the directory called “CaveWork” to transfer the images to. To do this we will use the terminal command 'mkdir'.

  • In a local terminal window you will need to 'cd' to the directory “CaveWork” and then 'mkdir' called “CaveImages”
personalcomputer:~ username$ cd Desktop/CaveWork

personalcomputer:CaveWork username$ mkdir CaveImages

personalcomputer:CaveWork username$ cd CaveImages

personalcomputer:CaveImages username$

We have now created the directory “CaveImages” and changed our current location to it.

  • Next we will open a new terminal window and locate the images and their path on Caveman using the ssh protocol as done previously. The images are in the directory called “SnapshotImages” located in the directory “Desktop” on Caveman.
personalcomputer:~ username$ ssh username@caveman.geology.ucdavis.edu

caveman:~ username$ cd Desktop/SnapshotImages

caveman:SnapshotImages username$ pwd
/Users/username/Desktop/SnapshotImages

caveman:SnapshotImages username$ ls

ScreenshotTool001.png
ScreenshotTool002.png
ScreenshotTool003.png
ScreenshotTool004.png

Now using the scp protocol we will copy the files from “SnapshotImages” on Caveman to the newly created directory “CaveImages” on our personal computer. To do this we will use the terminal window that was used to create the directory “CaveImages”. Since the current location of the terminal window is the directory “CaveImages” we can use the terminal command '.' (current directory) instead of typing out the path. Since we want to copy all of the images in “SnapshotImages” from Caveman we will use the terminal command '*' which is a wild card and can be used to state that you want all of a certain file type.

  • To do this we will use the scp protocol, state what files we want and where we want them to go.
personalcomputer:CaveImages username$ scp username@caveman.geology.ucdavis.edu:/Users/username/Desktop/SnapshotImages/*.png .

We have now copied all of the .png files from “SnapshotImages” from Caveman using 'scp', '*' (wild card), and '.' (current directory) to the newly created directory ('mkdir') “CaveImages”.

Copying an entire directory using scp

Instead of making a new directory as in the previous example you can also copy the directory with the files directly using 'scp -r'. Say we would like to copy the directory “SnapshotImages” from Caveman to the directory “Desktop” on our personal computer. To do this we 'scp -r', state what directory we want and its path and where it is we want to put it.

personalcomputer:~ username$ scp -r username@caveman.geology.ucdavis.edu:/Users/username/Desktop/SnapshotImages ~/Desktop

We have now copied the directory “SnapshotImages” from Caveman to the directory “Desktop” on our personal computer.

the command 'man'

The terminal command 'man' refers to all the user manual pages built in your system. In a terminal window you can type 'man' and then any terminal command and you will get the corresponding manual page for that command.

*

*Path: A path is a list of directories where the operating system looks for files. Essentially it is a list of locations on your computer from getting from point A to B.

*Directory: A directory is essentially the same thing as a folder. If you create a fold called “dogs” you have just created a directory called “dogs”.

keckcaves/transferring_data_remotely.txt · Last modified: 2011/07/06 12:25 by ewsteven