Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nodecentral opened this issue Dec 9, 2024 · 17 comments
Open

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

nodecentral opened this issue Dec 9, 2024 · 17 comments

Comments

@nodecentral
Copy link

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.

@bugy
Copy link
Owner

bugy commented Dec 9, 2024

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
Copy link
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
Copy link
Owner

bugy commented Dec 9, 2024

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
Copy link
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
Copy link
Owner

bugy commented Dec 10, 2024

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
Copy link
Author

nodecentral commented Dec 12, 2024

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
Copy link
Owner

bugy commented Dec 12, 2024

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
Copy link
Author

nodecentral commented Dec 14, 2024

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
Copy link
Author

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

@bugy
Copy link
Owner

bugy commented Dec 19, 2024

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
Copy link
Owner

bugy commented Dec 19, 2024

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

@bugy
Copy link
Owner

bugy commented Dec 19, 2024

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
Copy link
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
Copy link
Owner

bugy commented Dec 19, 2024

and where is script-server located?

@bugy
Copy link
Owner

bugy commented Dec 20, 2024

Hey @nodecentral , any update?

@nodecentral
Copy link
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
Copy link
Owner

bugy commented Dec 20, 2024

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants