-
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating Your Own Shell Commands
Mohamed Dief edited this page Feb 2, 2021
·
1 revision
- EasyShell Allows You To Add Your Own Commands And Scripts Into The Shell. So You Can Execute It And Pass User Inputs To It With an Easy Way. Instead Of Running Your Python Scripts With Long Commands. You Can Link Your Python Script Into EasyShell Them Execute It Every Time With a Single Command.
- The Basics Of Creating a Shell Command Is Based On Creating a Python Script With The Main Function On It Named
Run()
And Takes On Argument That's The User Input. Then You Can Whatever You Want On The Code. Even Outside It. While Importing The Code. Every Code Outside The Run Function Is Executed Too. Let's Start With The Basic Stuff:
# filename="base-encoder.py"
import base64
def Run(Input):
BInput = Input.encode('UTF-8')
Encoded = base64.b64encode(BInput)
Encoded = Encoded.decode('UTF-8')
print("Base64:" , Encoded)
- Now, To Link This Script We Should Put It Into
scripts
Folder. Then We Should Go Todata/Commands.easy
And Add a New Line. We Should Add Some Content With This FormatCommand="script-name-without-dot-py"
. Our Script Name, In This Case, Isbase-encoder.py
So We Will Add This Line.
base64="base-encoder"
- Then Comming Back To Our Shell. We Will Run EasyShell With
python3 shell.py
Then We Will Write That On The Shellbase64 - something
. And The Output Will BeBase64: c29tZXRoaW5n
. Really Easy.