R
Railwayā€¢13mo 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ā€¢13mo ago
Project ID: N/A
dwaynemac
dwaynemacā€¢13mo ago
N/A
Brody
Brodyā€¢13mo ago
you could print as json and use jq? but what's your usecase?
dwaynemac
dwaynemacā€¢13mo 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ā€¢13mo 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
dwaynemacā€¢13mo ago
ok, didnt know about this. i think i dont completely understand how railway CLI works šŸ˜…
Brody
Brodyā€¢13mo ago
ask away
dwaynemac
dwaynemacā€¢13mo ago
No description
dwaynemac
dwaynemacā€¢13mo ago
how do i get $DATABASE_URL set ?
Brody
Brodyā€¢13mo 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
dwaynemacā€¢13mo ago
missed something
No description
Brody
Brodyā€¢13mo ago
please read my messages a bit more carefully, you are missing the railway run part
Solution
dwaynemac
dwaynemacā€¢13mo ago
i manage to do it with
railway shell
railway shell
``
No description
dwaynemac
dwaynemacā€¢13mo ago
does it make sense?
Brody
Brodyā€¢13mo ago
yep you can do that with the shell too
dwaynemac
dwaynemacā€¢13mo ago
ok, i'll try that aproach. thx!
Brody
Brodyā€¢13mo ago
remember, there's always this method I mentioned
dwaynemac
dwaynemacā€¢13mo ago
i couldnt reproduce it with echo:
dwaynemac
dwaynemacā€¢13mo ago
No description
dwaynemac
dwaynemacā€¢13mo ago
(the last line is a blank return)
Brody
Brodyā€¢13mo ago
windows? Linux?
dwaynemac
dwaynemacā€¢13mo ago
macOS
Brody
Brodyā€¢13mo ago
worked for me (but im on windows)
No description
Brody
Brodyā€¢13mo ago
so just stick with railway shell
milo
miloā€¢13mo ago
what shell is that @dwaynemac
dwaynemac
dwaynemacā€¢13mo ago
zsh
milo
miloā€¢13mo ago
interesting, so railway run echo $DATABASE_URL gives a blank return? what's the exit status?
dwaynemac
dwaynemacā€¢13mo ago
i'll return in a minute ā²ļø
milo
miloā€¢13mo ago
šŸ‘
Brody
Brodyā€¢13mo ago
looks like the railway run command could benefit from the same shell detection code as railway shell any other questions? šŸ™‚
dwaynemac
dwaynemacā€¢13mo ago
for the time being i resolved using railway shell
Brody
Brodyā€¢13mo ago
awsome!
dwaynemac
dwaynemacā€¢13mo ago
sorry, how do i find this?
dwaynemac
dwaynemacā€¢13mo ago
No description
dwaynemac
dwaynemacā€¢13mo ago
does that help?
Brody
Brodyā€¢13mo ago
should be able to just run echo $? after that command
dwaynemac
dwaynemacā€¢13mo 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ā€¢13mo ago
after railway run run echo $? and that should tell you the exit code of railway run like milo asked for
dwaynemac
dwaynemacā€¢13mo ago
in the mean time i finished migrating another project from heroku to railway šŸ„³ aaah, ok.
dwaynemac
dwaynemacā€¢13mo ago
No description
dwaynemac
dwaynemacā€¢13mo ago
0
Brody
Brodyā€¢13mo ago
cool, thanks, milo said he'd look into this
Want results from more Discord servers?
Add your server