R
Railwayā€¢14mo ago
dwaynemac

getting single variable value through CLI

I've used
railway variables -k
railway variables -k
with grep. But is there a command to get a single variables value. Something like:
railway variables get VARNAME
railway variables get VARNAME
Solution:
i manage to do it with
railway shell
railway shell
``
No description
Jump to solution
42 Replies
Percy
Percyā€¢14mo ago
Project ID: N/A
dwaynemac
dwaynemacOPā€¢14mo ago
N/A
Brody
Brodyā€¢14mo ago
you could print as json and use jq? but what's your usecase?
dwaynemac
dwaynemacOPā€¢14mo ago
i wish to run a script similar to this:
pg_dump $(heroku config:get DATABASE_URL -r production) -F t -f latest.dump
pg_dump $(heroku config:get DATABASE_URL -r production) -F t -f latest.dump
Brody
Brodyā€¢14mo ago
you can just run
railway run pg_dump $DATABASE_URL -F t -f latest.dump
railway run pg_dump $DATABASE_URL -F t -f latest.dump
after linking to the project with railway link and selecting the service with railway service
dwaynemac
dwaynemacOPā€¢14mo ago
ok, didnt know about this. i think i dont completely understand how railway CLI works šŸ˜…
Brody
Brodyā€¢14mo ago
ask away
dwaynemac
dwaynemacOPā€¢14mo ago
No description
dwaynemac
dwaynemacOPā€¢14mo ago
how do i get $DATABASE_URL set ?
Brody
Brodyā€¢14mo ago
railway run runs the given command with the variables from the linked service set from your screenshot it looks like you need to link a service
dwaynemac
dwaynemacOPā€¢14mo ago
missed something
No description
Brody
Brodyā€¢14mo ago
please read my messages a bit more carefully, you are missing the railway run part
Solution
dwaynemac
dwaynemacā€¢14mo ago
i manage to do it with
railway shell
railway shell
``
No description
dwaynemac
dwaynemacOPā€¢14mo ago
does it make sense?
Brody
Brodyā€¢14mo ago
yep you can do that with the shell too
dwaynemac
dwaynemacOPā€¢14mo ago
ok, i'll try that aproach. thx!
Brody
Brodyā€¢14mo ago
remember, there's always this method I mentioned
dwaynemac
dwaynemacOPā€¢14mo ago
i couldnt reproduce it with echo:
dwaynemac
dwaynemacOPā€¢14mo ago
No description
dwaynemac
dwaynemacOPā€¢14mo ago
(the last line is a blank return)
Brody
Brodyā€¢14mo ago
windows? Linux?
dwaynemac
dwaynemacOPā€¢14mo ago
macOS
Brody
Brodyā€¢14mo ago
worked for me (but im on windows)
No description
Brody
Brodyā€¢14mo ago
so just stick with railway shell
milo
miloā€¢14mo ago
what shell is that @dwaynemac
dwaynemac
dwaynemacOPā€¢14mo ago
zsh
milo
miloā€¢14mo ago
interesting, so railway run echo $DATABASE_URL gives a blank return? what's the exit status?
dwaynemac
dwaynemacOPā€¢14mo ago
i'll return in a minute ā²ļø
milo
miloā€¢14mo ago
šŸ‘
Brody
Brodyā€¢14mo ago
looks like the railway run command could benefit from the same shell detection code as railway shell any other questions? šŸ™‚
dwaynemac
dwaynemacOPā€¢14mo ago
for the time being i resolved using railway shell
Brody
Brodyā€¢14mo ago
awsome!
dwaynemac
dwaynemacOPā€¢14mo ago
sorry, how do i find this?
dwaynemac
dwaynemacOPā€¢14mo ago
No description
dwaynemac
dwaynemacOPā€¢14mo ago
does that help?
Brody
Brodyā€¢14mo ago
should be able to just run echo $? after that command
dwaynemac
dwaynemacOPā€¢14mo ago
after railway shell? yes yes. i'm just trying to answer @milo / salvage 's question: about the exit status of the run command
Brody
Brodyā€¢14mo ago
after railway run run echo $? and that should tell you the exit code of railway run like milo asked for
dwaynemac
dwaynemacOPā€¢14mo ago
in the mean time i finished migrating another project from heroku to railway šŸ„³ aaah, ok.
dwaynemac
dwaynemacOPā€¢14mo ago
No description
dwaynemac
dwaynemacOPā€¢14mo ago
0
Brody
Brodyā€¢14mo ago
cool, thanks, milo said he'd look into this
Want results from more Discord servers?
Add your server