Skip to content

Run just as a terminal window - allow command line input? #777

@nodecentral

Description

@nodecentral

Hi,

Is it possible to have a runner & script that just allows a user to interact via just the command line, and see their commands and responses come up ? I hoped it might be as simple as having a having a .json runner with something as simple as below, but that doesn’t seem to work ?

  "requires_terminal": "true",
  "output_format": "terminal"

To provide more context, one of the drivers for this is to load .yaml files for an application called Organize which from the command line I would run a configuration like this organize sim config_tech.yaml ? The good thing about this is that the yaml files do not have to be executables..

Would a potential option to achieve this, be to use parameters and see if it’s possible to have people load these Organize configuration files from a pick list (as they are all stored in a folder) ?

Any ideas suggestions much appreciated.

Activity

bugy

bugy commented on Dec 9, 2024

@bugy
Owner

Hi @nodecentral, I think you are asking for full-fledged terminal and bash support. For this you could just run bash potentially and then it will consume all users commands. But script server output window is not well-designed for interactive behaviour.
But I guess the proper way would be to give parameters for Organize

nodecentral

nodecentral commented on Dec 9, 2024

@nodecentral
Author

Hi @bugy thanks so much for responding, having just bash in a script gives me the direct terminal feel, many thanks.

When it comes to creating an interactive pick list, allowing me to select and run any one of a list of Organize .yaml config files? Is there a way I can use a parameter options to look to a defined folder and build a dynamic list of the files in there.

Or does every file have to be hard coded into a file

bugy

bugy commented on Dec 9, 2024

@bugy
Owner

Hi @nodecentral , sure. You can use this parameter type https://github.com/bugy/script-server/wiki/Script-config#server_file
Or if you need more dynamic behavior, you can use this parameter type https://github.com/bugy/script-server/wiki/Script-config#list and define a script which will resolve possible values

nodecentral

nodecentral commented on Dec 9, 2024

@nodecentral
Author

Thanks @bugy

I was looking at the server_file option, but I’m not sure what the script (in script_path needs to be)?

{
  "name": "Organize Configuration Pick List",
  "script_path": "???",
  "working_directory": "./organize",
  "group": "Demos",
  "description": "This script presents a drop-down - pick list of Organize configs to run ",
  "allowed_users": [
    "*"
  ],
  "include": "${Simple Text}.json",
  "parameters": [
    {
},
    {
      "name": "Server file",
      "param": "--server_file",
      "type": "server_file",
      "secure": true,
      "file_dir": "./",
      "file_extensions": [
        "yaml"
      ],
      "excluded_files": [
        "*.txt*",
        "*.jpg*"
      ]
    },
]
}

the dynamic option looks interesting, but it’s well out of my coding skills..

bugy

bugy commented on Dec 10, 2024

@bugy
Owner

Script path will be organize sim i guess in this case
Also you wouldn't need "param" option
Also, make sure to remove empty curly braces

nodecentral

nodecentral commented on Dec 12, 2024

@nodecentral
Author

Thanks @bugy , is this looking right ?

Some questions.

  1. I’ve called out the same directory in working_directory and file_dir? They’re both point to where all the xxxxx.yaml files are stored ? Do I need both ?
  2. what sort of script do I need a script in script_path, it needs to receive the chosen parameter from the pick list and pass that to the required command, which would simple be organize runand then e.g. what’s chosen e.g. config_tech.yaml ? Do you have any examples I could use?
  3. finally, the "include": "${Simple Text}.json is that even needed here?
{
  "name": "Organize Configuration Pick List",
  "script_path": "???",
  "working_directory": "./organize",
  "group": "Demos",
  "description": "This script presents a drop-down - pick list of Organize configs to run ",
  "allowed_users": [
    "*"
  ],
  "include": "${Simple Text}.json",
  "parameters": {
    "name": "Organize Configs",
    "type": "server_file",
    "secure": true,
    "file_dir": "./organize",
    "file_extensions": [
      "yaml"
    ],
    "excluded_files": [
      "*.txt*",
      "*.jpg*"
    ]
  }
}
bugy

bugy commented on Dec 12, 2024

@bugy
Owner

Hey, please check my previous answer regarding script path
Working directory is probably not needed.
Include is not needed
Parameters should be an array, i.e. add square braces before and after

In general, i highly recommend not to copy examples. They usually have way more stuff than needed for people's use cases. If you don't know what an option does, then most probably you don't need it

nodecentral

nodecentral commented on Dec 14, 2024

@nodecentral
Author

Thanks @bugy, having not done this before, hopefully I’m getting closer, how is this looking ?

Recap on the objective : Script that will allow me to look up to the ./organize folder, to pick a .yaml file (from an auto-generated list of all available .yaml files) e.g. photos.yaml and send it to the command line to be prefixed with organize sim and run. (The resulting combined command line entry is organize sim photos.yaml(

{
  "name": "Organize Configuration Pick List",
  "script_path": "organize sim",
  "group": "Demos",
  "description": "This script presents a pick list of Organize configs files to choose andf run ",
  "parameters": [
  {
    "name": "Organize Configs",
    "type": "server_file",
    "file_dir": "./organize",
    "file_extensions": 
	[
      "yaml"
    ]
  }
    ]
}

Not able to get it to work at the moment, pick list not returning anything, and if I execute it as it, it does this..

Not sure why/where it is pulling the string “config” as search criteria ?

image
nodecentral

nodecentral commented on Dec 19, 2024

@nodecentral
Author

Sorry @bugy, any further advice on how I’d get this to work would be great.. many thanks

bugy

bugy commented on Dec 19, 2024

@bugy
Owner

Hi @nodecentral sorry for a late response. Where is your organize folder is located? Relative to script-server folder

If you open "history" tab at the bottom, you can see, which command is actually executed. What does it show for you?

bugy

bugy commented on Dec 19, 2024

@bugy
Owner

You can also check script-server logs (either stdout or logs/server.log)

bugy

bugy commented on Dec 19, 2024

@bugy
Owner

I created organize folder inside script-server folder and yaml files are correctly displayed in the dropdown list for me. When I use the config, provided by you

nodecentral

nodecentral commented on Dec 19, 2024

@nodecentral
Author

Hey @bugy thanks for responding.

I've moved it around since, trying different locations, using the bash script I created earlier to manually run them, all the *.yaml files are in app/scripts/organize/

root@48dda3453173:/app/scripts# ls
organize
bugy

bugy commented on Dec 19, 2024

@bugy
Owner

and where is script-server located?

bugy

bugy commented on Dec 20, 2024

@bugy
Owner

Hey @nodecentral , any update?

nodecentral

nodecentral commented on Dec 20, 2024

@nodecentral
Author

Hey @bugy, sorry I didnt get your reply.

I've installed ScriptServer via docker, here are my volume/binds

    volumes:
      - /share/Container/script-server/conf/conf.json:/app/conf/conf.json
      - /share/Container/script-server/runners/:/app/conf/runners
      - /share/Container/script-server/scripts/:/app/scripts/
      - /share/Container/script-server/organize/logs:/var/log/organize
      - /share/Container/script-server/organize/config:/root/.config/organize
      - /share/Publications:/app/qnap/publications
      - /share/Container/avpn:/app/qnap/avpn
      - /share/Movies:/app/qnap/movies
    ports:
      - 5012:5000
bugy

bugy commented on Dec 20, 2024

@bugy
Owner

And in which host (original) folder are your yaml files located? Is it share/Container/script-server/organize/config? Then you can use /root/.config/organize as a path in the parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bugy@nodecentral

        Issue actions

          Run just as a terminal window - allow command line input? · Issue #777 · bugy/script-server