C2110 UNIX and programming Lesson 2 / Module 4 -1C2110 UNIX and programming Petr Kulhanek kulhanek@chemi.muni.cz National Center for Biomolecular Research, Faculty of Science Masaryk University, Kamenice 5, CZ-62500 Brno Lesson 2 / Module 4 PS / 2020 Distance form of teaching: Rev1 C2110 UNIX and programming Lesson 2 / Module 4 -2Remote File Transfer ➢ scp (rsync) ➢ wget (curl) ➢ Data Transfer Between Unix/macOS OS and MS Windows (WinSCP) C2110 UNIX and programming Lesson 2 / Module 4 -3Remote Copying $ scp [-r] source target Examples of use: Syntax: [] - can be omitted Source and target can be a file or a directory. When copying directories, the option -r (recursive) must be used. The remote destination or host is identified by the machine name separated from the file or directory name by a colon. [user@]hostname:[/path/]file $ scp test.txt wolf01.ncbr.muni.cz:/scratch/kulhanek $ scp wolf01.ncbr.muni.cz:/scratch/kulhanek/test.txt . Use the command scp for remote copying. The command more convenient for copying a larger amount of data (directory synchronization) is rsync (C2115). C2110 UNIX and programming Lesson 2 / Module 4 -4Exercise 1 1. Make a copy of the directory ~/Documents/ C2110 to the directory /scratch/username (make sure you have some files in the directory ~ /Documents/C2110, e.g., a presentations for exercises). 2. Copy the contents of the directory /scratch/username/Documents to the remote machine of your choice into the directory /scratch/username/wolfXX, where wolfXX is the number of the source machine. Use the command to scp. 3. Delete directories /scratch/username/Documents and /scratch/username/wolfXX use two terminals username - your username C2110 UNIX and programming Lesson 2 / Module 4 -5Downloading Files from the Web You can use the command wget to download files from the web. Remote machines must provide files using a ftp, http or https protocol. $ wget [-O output_name] url url (uniform resource locator) www file identifier Examples of use: $ wget http://www.rcsb.org/pdb/files/1SS9.pdb PDB code structure big O A similar command is curl. However, it allows two-way communication with a remote machine. C2110 UNIX and programming Lesson 2 / Module 4 -6Exercise 2 1. Use the wget command to download the 1SS9 PDB structure to a file named structure.pdb and save it to a directory ~/Documents/C2110 2. Download the installation image using the wget command (iso file) for Ubuntu Server 18.04 to the directory /scratch/username. Verify its checksum by command md5sum or sha256sum. 3. Delete the installation image. username - your username C2110 UNIX and programming Lesson 2 / Module 4 -7Data Transfer MS Windows <> UNIX Text files created under MS Windows and Linux (macOS) are not completely compatible because each operating system uses a different encoding for end of line. Linux (macOS): \n (line feed 0x0A) MS Windows: \r+\n (carriage return 0x0D, line feed 0x0A) For coding conversion, see C2110-CZ-MSWindows-M01.pdf C2110 UNIX and programming Lesson 2 / Module 4 -8- Homework C2110 UNIX and programming Lesson 2 / Module 4 -9- Homework 1. Download the presentation from the directory /home/kulhanek/Documents/C2110/Presentations to your computer with WinSCP or scp commands. Presentations are available in the format pdf and commented presentations in mkv format (video).