43. Overview of CLI utility use from Code editor - Ayushi-srivastav/OCI GitHub Wiki
Overview
The OCI Code Editor is a browser-based integrated development environment (IDE) that enables users to edit and manage code directly within the Oracle Cloud Infrastructure (OCI) Console. It offers a seamless development experience without the need for additional local setups.
The OCI CLI (Command Line Interface) Utility empowers developers and administrators to automate tasks, manage cloud resources, and interact efficiently with OCI services.
This document covers:
✅ Navigating to Code Editor
✅ Using CLI Utility within OCI
✅ Running basic CLI commands
1. Navigating to OCI Code Editor
To access the OCI Code Editor, follow these steps:
(a) Open the OCI Console
Log in to your OCI Console using your credentials.
(b) Open Code Editor
Click on the Cloud Shell icon located in the top-right corner of the OCI Console.
- From the dropdown menu, select Code Editor.
(c) Launch Code Editor
Once inside, you will see an IDE-like interface with a file explorer, terminal, and code editor.
2. Creating a New Folder & Running a Shell Script in OCI Code Editor
In OCI Code Editor, you can organize your files by creating folders and adding scripts. Follow the steps below to create a new folder, add a shell script, and execute it.
(a) Create a New Folder
-
Click on the Explorer icon on the left sidebar.
-
Right-click inside the file explorer and select "New Folder".
-
Name the folder "OCI" and press Enter.
(b) Create a Shell Script
-
Inside the OCI folder, right-click and select "New File".
-
Name the file cli.sh.
- Open the newly created cli.sh file and add the following script
(c) Run the Shell Script
- Right-click on cli.sh and select "Open in Integrated Terminal".
oci cli -v
oci compute instance list --compartment-id <compartment_ocid>
Some more scripting --
oci compute instance get --instance-id <instance_ocid>
oci compute instance get --instance-id <instance_ocid>
./cli.sh
- Provide execute permissions to the script
chmod 700 cli.sh
- Run the script
By following these steps, you have successfully created a folder, written a shell script, and executed it in OCI Code Editor
Now create a file named output.txt . In which the script’s output will be stored
./cli.sh >output.txt
- Additionally, you have the option to download the script for future use.