globus_command_line_interface.md 5.35 KB
Newer Older
eharstad's avatar
eharstad committed
1
2
3
4
5
+++
title = "Globus Command Line Interface"
description = "How to use the Globus Command Line Interface to transfer files"
weight = 70
+++
6
7
8
9
10
11
12

Globus Command Line Interface (CLI) provides an interface to Globus
services from the shell and can be incorporated into scripts or used
interactively. The CLI allows users to transfer files and manipulate
directory structures on a remote endpoint without use of the web
interface.

eharstad's avatar
eharstad committed
13
14
---
### Connecting to Globus on the Command Line
15
16
17
18
19
20

To establish a Globus connection, a user must connect their HCC account
to their Globus account. To do so, follow these steps:

1.  Connect to the desired HCC cluster.
2.  Load the Globus CLI module:
eharstad's avatar
eharstad committed
21
{{< highlight bash >}}module load globus-cli {{< /highlight >}}
22
23
24
25

3.  Use the command \`globus login\` to start the authorization
    procedure. A web address will be displayed on screen. Copy and paste
    this URL into your browser.  
eharstad's avatar
eharstad committed
26
27
{{< figure src="/images/21071052.png" >}}      

28
4.  If you are not already logged into Globus, do so now.
eharstad's avatar
eharstad committed
29

30
31
5.  Label the connection if desired, then click Allow to grant Globus
    the permissions outlined on the screen.
eharstad's avatar
eharstad committed
32
33
34
35
36
37
{{< figure src="/images/21071053.png" >}}

6. Copy the Authorization Code and paste it into the prompt in your
    terminal. 
{{< figure src="/images/21071054.png" >}}
{{< figure src="/images/21071055.png" >}}
38

eharstad's avatar
eharstad committed
39
40
7.  At this point, you can verify you are logged in:
{{< highlight bash >}}globus whoami{{< /highlight >}}
41
42
43
44
45
46

    If you have logged in, you will see your email address displayed. If
    not, the message "No login information available." will be
    displayed.

8.  To terminate your Globus connection:
eharstad's avatar
eharstad committed
47
{{< highlight bash >}}globus logout{{< /highlight >}}
48

eharstad's avatar
eharstad committed
49
50
---
### Activating a Globus Endpoint
51
52

To find available endpoints:
eharstad's avatar
eharstad committed
53
{{< highlight bash >}}globus endpoint search search_term{{< /highlight >}}
54
55
56

Where search\_term is replaced with the keyword you wish to search for.
For example:
eharstad's avatar
eharstad committed
57
{{< highlight bash >}}globus endpoint search hcc{{< /highlight >}}
58
59

will display any endpoint with "hcc" in it's Display Name.
eharstad's avatar
eharstad committed
60
{{< figure src="/images/21071056.png" >}}
61
62

To use the endpoint, you can refer it it by it's UUID number. To
63
activate an endpoint, use the command `globus endpoint activate --web`:
eharstad's avatar
eharstad committed
64
{{< figure src="/images/21073509.png" >}}
65
66
67
68
69

Copy the given URL and paste it into the address bar of your web
browser. If you are not already logged into the Globus website, you will
be prompted to do so. Once you are logged in, you need to click the
\`Activate Now\` button to activate the endpoint.
eharstad's avatar
eharstad committed
70
{{< figure src="/images/21073503.png" >}}
71
72
73
74

Once an endpoint is activated, it will remain activate for 7 days. You
can now transfer and manipulate files on the remote endpoint.

eharstad's avatar
eharstad committed
75
{{% notice info %}}
76
77
78
79
To make it easier to use, we recommend saving the UUID number as a bash
variable to make the commands easier to use. For example, we will
continue to use the above endpoint (Tusker) by assigning its UUID code
to the variable \`tusker\` as follows:
eharstad's avatar
eharstad committed
80
{{< figure src="/images/21073499.png" >}}
81
82
83
84
85

This command must be repeated upon each new login or terminal session
unless you save these in your environmental variables. If you do not
wish to do this step, you can proceed by placing the correct UUID in
place of whenever you see \`$tusker\`.
eharstad's avatar
eharstad committed
86
{{% /notice %}}
87
  
eharstad's avatar
eharstad committed
88
89
---
### Endpoint Manipulation
90
91
92
93
94
95
96

Globus CLI supports the commands \`mkdir\`, \`rename\`, and \`ls\`. All
globus commands follow the format \`globus &lt;command&gt;
&lt;endpoint&gt;:&lt;file\_path&gt;\`. We can list the files on the
remote endpoint with the command \`globus ls\`. To list the files in the
home directory on the remote endpoint, we would use the following
command:
eharstad's avatar
eharstad committed
97
{{< figure src="/images/21073500.png" >}}
98
99
100
101

To make a directory on the remote endpoint, we would use the \`globus
mkdir\` command. For example, to make a folder in the users work
directory on Tusker, we would use the following command:
eharstad's avatar
eharstad committed
102
{{< figure src="/images/21073501.png" >}}
103
104
105
106

To rename files on the remote endpoint, we can use the \`globus rename\`
command. To rename the test file we just created above, we would use the
command:
eharstad's avatar
eharstad committed
107
{{< figure src="/images/21073502.png" >}}
108

eharstad's avatar
eharstad committed
109
110
---
### Single Item Transfers
111
112
113
114
115
116
117
118
119
120
121
122

All transfers must take place between Globus endpoints. Even if you are
transferring from an endpoint that you are already connected to, that
endpoint must be activated in Globus. Here, we are transferring between
Crane and Tusker. We have activated the Crane endpoint and saved its
UUID to the variable $crane as we did for $tusker above.

To transfer files, we use the command \`globus transfer\`. The format of
this command is \`globus transfer &lt;endpoint1&gt;:&lt;file\_path&gt;
&lt;endpoint2&gt;:&lt;file\_path&gt;\`. For example, here we are
transferring the file \`testfile.txt\` from the home directory on Crane
to the home directory on Tusker:
eharstad's avatar
eharstad committed
123
{{< figure src="/images/21073505.png" >}}
124
125
126

You can then check the status of a transfer, or delete it all together,
using the given Task ID:
eharstad's avatar
eharstad committed
127
{{< figure src="/images/21073506.png" >}}
128
129
130
131
132

To transfer entire directories, simply specify a directory in the file
path as opposed to an individual file. Below, we are transferring the
\`output\` directory from the home directory on Crane to the home
directory on Tusker:
eharstad's avatar
eharstad committed
133
{{< figure src="/images/21073507.png" >}}
134
135

For additional details and information on other features of the Globus
eharstad's avatar
eharstad committed
136
CLI, visit [Command Line Interface (CLI) Examples](https://docs.globus.org/cli/examples/) in the Globus documentation.
137
138

  
eharstad's avatar
eharstad committed
139
---