| 485 | ==== Temporarily Setting Environment Variables ==== |
| 486 | As an alternative to the above, you can avoid possible confusion associated with environment variable values by temporarily setting those variables and invoking a command, e.g. `idev`, all on one line. Thus, when you exit from the interactive session, those variables will be restored to their prior state. Furthermore, you can define and use an alias, e.g. "idevi", as in the following. |
| 487 | |
| 488 | Starting from the login session, observe variables initially unset. |
| 489 | {{{ |
| 490 | [fuji@cypress1 ~]$ echo MY_PARTITION=$MY_PARTITION, MY_QUEUE=$MY_QUEUE |
| 491 | MY_PARTITION=, MY_QUEUE= |
| 492 | }}} |
| 493 | Define and invoke alias "idevi", now entering the interactive session. |
| 494 | {{{ |
| 495 | [fuji@cypress1 ~]$ alias idevi='MY_PARTITION=interactive MY_QUEUE=interactive idev' |
| 496 | [fuji@cypress1 ~]$ idevi |
| 497 | Requesting 1 node(s) task(s) to interactive queue of interactive partition |
| 498 | 1 task(s)/node, 20 cpu(s)/task, 2 MIC device(s)/node |
| 499 | Time: 0 (hr) 60 (min). |
| 500 | Submitted batch job 1255374 |
| 501 | JOBID=1255374 begin on cypress01-089 |
| 502 | --> Creating interactive terminal session (login) on node cypress01-089. |
| 503 | --> You have 0 (hr) 60 (min). |
| 504 | --> Assigned Host List : /tmp/idev_nodes_file_fuji |
| 505 | Last login: Thu Dec 19 12:27:32 2019 from cypress1.cm.cluster |
| 506 | }}} |
| 507 | In the interactive session, evaluate the variables and observe they are set. |
| 508 | {{{ |
| 509 | [fuji@cypress01-089 ~]$ echo MY_PARTITION=$MY_PARTITION, MY_QUEUE=$MY_QUEUE |
| 510 | MY_PARTITION=interactive, MY_QUEUE=interactive |
| 511 | }}} |
| 512 | In the interactive session, do work, then exit back to the login session. |
| 513 | {{{ |
| 514 | ... |
| 515 | [fuji@cypress01-089 ~]$ exit |
| 516 | logout |
| 517 | Connection to cypress01-089 closed. |
| 518 | Removing job 1255374. |
| 519 | |
| 520 | [fuji@cypress1 ~]$ |
| 521 | }}} |
| 522 | Back in the login session, observe the variables are restored to their prior state - in this case unset. |
| 523 | {{{ |
| 524 | [fuji@cypress1 ~]$ echo MY_PARTITION=$MY_PARTITION, MY_QUEUE=$MY_QUEUE |
| 525 | MY_PARTITION=, MY_QUEUE= |
| 526 | }}} |
| 527 | |