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

[Windows] - Script Powershell - problem ANSI #419

Closed
BConcept59 opened this issue Mar 26, 2021 · 10 comments
Closed

[Windows] - Script Powershell - problem ANSI #419

BConcept59 opened this issue Mar 26, 2021 · 10 comments

Comments

@BConcept59
Copy link

Hi,

I would like thank @bugy for Script-Server ! It's very good software !

I my script powershell, the data is good with the special characters ( é à è ... ). But in the combobox it isn't good in the view.
It remplace the special characters by ","

Do you have a solution ?

Thank for advance

@bugy
Copy link
Owner

bugy commented Mar 26, 2021

Hi, which script server version are you using?
Also, which encoding is used in your script?
Stable script server version works with utf8. Dev version has some extended encoding support, but not much

May be you can try a workaround from #376 (comment)
The wrapper with iconv

@BConcept59
Copy link
Author

I use version 1.16.0 Script-Server

My script use UTF8 BOM and adding -Encoding UTF8 on my cmd for forced the coding.

Line :
get-content ./src/features/__Informations__/$Company_File.list -Encoding UTF8

i don't have Iconv on Windows.

@bugy
Copy link
Owner

bugy commented Mar 26, 2021

Hi, @BConcept59 I made it work on my windows machine, by adding this line at the beginning of the PowerShell script:
[Console]::OutputEncoding = [System.Text.Encoding]::Default

The problem is, that when run on windows (at least win10), script server is using default system encoding (e.g. cp1251 for me). However, PowerShell writes output (by default) in utf-8 (with or without BOM, doesn't matter).
By adding the line above, powershell is made to write output in system default encoding

Could you try it, please?

@BConcept59
Copy link
Author

I have add [Console]::OutputEncoding = [System.Text.Encoding]::Default in my script and it's good !

Very thanks

I have a two other problems...

  1. Always UTF8 error but with the information provided by the user in the input fields.

the input return :

powershell -ExecutionPolicy Unrestricted -Command ./script_005.ps1 -LastName Hir Tone -Firstname églantine -Company RESIDENCE LA GENTILHOMMIERE -SharedMailBox Accueil -Title Agent d'accueil

  1. Always in input return, how to do for adding ( ' ). Because my value is truncate in my script.

Example : -LastName Hir Tone --> -LastName 'Hir Tone'

@bugy
Copy link
Owner

bugy commented Mar 26, 2021

Hi, @BConcept59 to be honest I don't fully understand you. Maybe you can send me a part script-server/logs/server.log file, which corresponds to script invocation?

@BConcept59
Copy link
Author

Sorry for my english.

In log server :

2021-03-26 21:20:50,552 [web_server.INFO] Calling script Créer un utilisateur. User {'ip': '127.0.0.1', 'hostname': 'AZAPPS001.univi.lan'} 2021-03-26 21:20:50,554 [script_server.execution_service.INFO] Calling script #39: powershell -ExecutionPolicy Unrestricted -Command ./script_005.ps1 -LastName béal -Firstname AR to -Company RESIDENCE LA GENTILHOMMIERE -SharedMailBox Accueil -Title Agent d'accueil

I need to add simple quotes for the sent values.

Example:

-Company RESIDENCE LA GENTILHOMMIERE

should be

-Company 'RESIDENCE LA GENTILHOMMIERE'

@bugy
Copy link
Owner

bugy commented Mar 26, 2021

For me it worked, when I passed the script path with -file argument
Works (parameters with whitespaces are parsed as a single argument):
"script_path": "powershell -file 'path\\to\\encoding_419_bug.ps1'",

Does not work (parameters with whitespaces are sent separately):
"script_path": "powershell 'path\\to\\encoding_419_bug.ps1'",

Could you try, please?

@bugy
Copy link
Owner

bugy commented Mar 29, 2021

Hi @BConcept59 any success here?

@bugy bugy added the question label Mar 29, 2021
@BConcept59
Copy link
Author

Hi @bugy , yes it's success ! Very thanks.

Sorry for my delay.

@bugy
Copy link
Owner

bugy commented May 5, 2021

Cool, thanks for confirmation

@bugy bugy added the resolved label May 5, 2021
@bugy bugy closed this as completed May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants