question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set variable to command output

See original GitHub issue

Describe the bug

I would like to be able to create a notebook without revealing any API keys, so I wanted to set a shell variable to avoid command output with API keys being visible. Unfortunately it doesn’t appear to be possible to use $(command) command substitution, or backticks. I even tried using read

Steps to reproduce the behavior

  1. Try to set a variable using one of the following…
export KEY=$(command)

or…

export KEY=`command`

or…

command | read KEY; export KEY

Expected behavior

I should be able to use the $KEY environment variable in subsequent commands

Screenshots If applicable, add screenshots to help explain your problem.

image

System

  • Kui version: recent (I couldn’t find the version in the UI anywhere, sorry)
  • Operating system: OSX

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
starpitcommented, Jun 9, 2021

This should be doable. We’ll take a shot at it for the upcoming 10.4.0 release.

1reaction
oskaptcommented, Jun 6, 2021

Please reopen this. It’s still an issue.

I am keen on using Kui with trainings that I do for SUSE/Rancher. It would make it easy for students to follow along and have the notebooks use variables that automatically customize themselves for each student’s environment:

export IP=$(kubectl get service/traefik -n kube-system -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export PORT=$(kubectl get service/demo -o jsonpath='{.spec.ports[0].nodePort}')
curl -I $IP:$PORT

Every time I try this, I run into this limitation around command substitution. It would be excellent if Kui supported it so that notebooks could be adaptable, allowing students to focus on learning instead of focusing on figuring out what IP was assigned to the ingress controller in their specific distribution of Kubernetes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to assign env variable using a command's output
I can set environment variables like this. ➤ foo=bar env | grep foo foo=bar. But, what if, I can only get foo=bar ...
Read more >
Unable to assign output of command to a variable [duplicate]
But when I try to assign the output of the command to a variable then it gives error. as ./update.sh: line 12: platform:...
Read more >
Environment variables to configure the AWS CLI
Environment variables provide another way to specify configuration options and credentials, and can be useful for scripting or temporarily setting a named ...
Read more >
How to use variables in Azure CLI commands | Microsoft Learn
In this article. Prerequisites; Use shell variables; Set a subscription; Create default values; Use persistent values; Clean up resources ...
Read more >
Set - Environment Variable - Windows CMD - SS64.com
Type SET with a variable name to display that variable. SET _department. The SET command invoked with a string (and no equal sign)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found