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

Create a test user shell script result output format (csv) #712

Closed
haskell-monad opened this issue Apr 11, 2019 · 2 comments
Closed

Create a test user shell script result output format (csv) #712

haskell-monad opened this issue Apr 11, 2019 · 2 comments

Comments

@haskell-monad
Copy link
Contributor

wire-server/deploy/services-demo/create_test_user.sh

When I execute on mac, the output is:

# Current *sed* statement
UUID=$(echo "$CURL_OUT" | tail -1 | sed 's/.*"id":"\([0-9a-z-]\+\)".*/\1/')

# Output result (csv)
{"email":"l8TVlbK0@example.com","locale":"en","accent_id":0,"picture":[],"name":"demo","id":"29740ea6-c54a -4a92-8fd5-3f8c5b05cdc3","assets":[]},l8TVlbK0@example.com,UfsMqsUD

I can't match the id. After escaping the double quotes (\"\"), I get the expected result:

# Modified *sed* statement
UUID=$(echo "$CURL_OUT" | tail -1 | sed 's/.*\"id\":\"\([a-z0-9-]*\)\".*/\1/')

# Output result (csv)
29740ea6-c54a-4a92-8fd5-3f8c5b05cdc3,l8TVlbK0@example.com,UfsMqsUD

I think wire is also intended to output result formats like id, email, password.

@fisx
Copy link
Contributor

fisx commented Apr 15, 2019

So what happens is that sed doesn't match the pattern that is supposed to extract the id field from the json object, and leaves the entire object intact.

The value that you show contains a space in the id field; if i fix that, it works fine:

$ echo '{"email":"l8TVlbK0@example.com","locale":"en","accent_id":0,"picture":[],"name":"demo","id":"29740ea6-c54a-4a92-8fd5-3f8c5b05cdc3","assets":[]}' | sed 's/.*"id":"\([0-9a-z-]\+\)".*/\1/'
29740ea6-c54a-4a92-8fd5-3f8c5b05cdc3

Are you sure you got this spurious space from the wire backend? If so, I would be very interested in help to reproduce this.

Other ideas: which sed are you using? Have you tried the one inside, say, https://quay.io/repository/wire/brig?

@haskell-monad
Copy link
Contributor Author

The space in the id is my mistake ^_^ , I tried again. The sed on the Linux server does not need to escape double quotes (\"\"). The sed on the Mac notebook needs to escape double quotes. Most of the production environment is Use the Linux server, so this issue can be closed.

@fisx fisx mentioned this issue Apr 15, 2019
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