0

I need help to create a custom Linux command. I cannot get bash to recognize my script and its arguments.

This command needs to fulfill these requirements:

  1. Expect root privileges.
  2. Expect arguments.
  3. Preferably be written in Python 3.

The goal of this command is to install/remove software from both Ubuntu and Snap repositories (favoring snap repos) and upgrade said packages/snaps. Any help is appreciated.

Here is the code I have so far:

    # import needed modules
    import os
    #create a list for input
    inlist = []
    #read input

    A = input()
    # break each word
    inlist = A.split()
    app = inlist[2]
    #install software
    if inlist[1] == 'install':

        #try to install snap
        os.system('sudo snap install '+app'
        #try to install with apt-get

    #remove software

        #try to remove snap

            #use try except block

            #try to install wihout paying

            #except to install with paying

        #try to remove with apt-get

    #find software

        #try to find snap

        #try to find with apt-get

    #test package or snap

    #autoremove

    #upgrade

    #install .deb

    #run software

1 Answers1

0

For clarity, I believe you mean you're trying to create a Python 3 script that can perform the function you're after.

With that said I believe you'll have better luck with this type of question in Stack-overflow as this is more about programming than Linux.

But to answer the question I think you're asking. You'll either need to run this script with python in front of the command (ie python3 filename) or give it execute permissions and call it directly (ie chmod +x filename; ./filename).

Jay Holister
  • 131
  • 2