bugy / script-server

Web UI for your scripts with execution management
Other
1.55k stars 246 forks source link

Pass variable to script shell from browser #566

Closed Trawx closed 2 years ago

Trawx commented 2 years ago

Hi @bugy

I really have liked your script server . just I still missing one point, could you please explain to me how I can enter variables to my script throw browser? example:

in commande line I can run my script.sh like this: # source ./myscript.sh var1 var2 is this possible to made using your script server ? I want to enter it through browser like this image

and this is the configuration on Admin side image

could you support please, Vielen dank :D

bugy commented 2 years ago

Hi @Trawx, 2 things:

  1. The file path, which you are passing, should be a path on a server. Browsers have no way to access user's filesystem on their own. If you want to access a user's file from a server, you have to use file upload parameter
  2. There should be no quotes in the path
Trawx commented 2 years ago

hi @bugy,

yes you are right, just I want know how I can enter 2 variables to my script from browser. example let say that I have script shell for a calculator and I want to do something like this:

source ./myscript.sh 1 4

that means the script will took first variable is "1" and second is "4". is that possible to made using script server ?

many thanks to you !

bugy commented 2 years ago

Hi @Trawx I'm confused. You are doing it already :) Based on your screenshots

Trawx commented 2 years ago

@bugy

I'm doing it but it's not working, I have 2 variables "PASSWORD" and "PATH". don't get confused with PATH. it's just variable not a file.

I have create a script in Admin panel, then I have entered 2 parameters. ( is the configuration on the previous picture is correct ?

this is what I see on logs: Calling script #28: /home/ubuntu/tmp/conf/scripts/sync_images_windows.sh $1 ** $2 'C:/Users/Ghassen/Desktop/myphotos'

my script.sh :

password="$1" path="$2"

then I will use those 2 variables in my script.

is all this correct, thanks again

bugy commented 2 years ago

please remove $1 $2 a param section

bugy commented 2 years ago

You only need these 3 options: image

Everything else should be empty/disabled (except password, where you should use secret)

Trawx commented 2 years ago

thank you @bugy , you save my day! I don't know how the generated json file doesn't take my changes. so I changed manually and remove $1 $2 . thank you again we can close this issue.

bugy commented 2 years ago

I'm glad it worked :)