Ask coding questions

← Back to all posts
Access Linux terminal in Python or Ruby on Rails
K_log (5)

Is it possible to get to the command prompt in Python or Ruby on Rails? For python, it seems that it will only run the python terminal and for Ruby on Rails, it either auto starts the server or wont let you run commands which is a problem because I dont know of another way to generate things in Rails.

Answered by IbraheemRodrigues (88) [earned 5 cycles]
View Answer
IbraheemRodrigues (88)

Probably a bit late now, but press F1 to open the command palette and then type Open Shell

nehatkhan786 (1)

brother this is not working with me. I press f1 but nothing shows [email protected]

IbraheemRodrigues (88)

Sometimes doesn't seem to work (depending on browser probably) - if so right click in the editor pane and select open command palette at the bottom, then search for Open Shell@nehatkhan786

JohnWilliams2 (2)

You can also hit Ctrl + shift + s

K0DYungDeku (0)

Wish I could inbox on here

K_log (5)

I already know that there are a lot of ways to run commands using Python or Ruby but what I'm trying to do is get access to the command line in a through the online editor of this site specifically without having to run my commands through a script.

ash15khng (723)

If I understand correctly there is a bash repl available on

leon332157 (345)

Do you mean you wanna execute a command in Python/Ruby script or access the ternmal from the script?

leon332157 (345)

And also if want to contact me from email: [email protected] discord:leon332157#2603

K_log (5)

@leon332157 I'm trying to be able to run commands like 'rails generate scaffold User' or 'flask db init' but those require a bash terminal, not a python/ruby interpreter. I'm wondering if there is a way to execute such commands without having to write a program to execute the commands in a terminal for me like exec in c.

replitcode (149)

@K_log there's this... but it only works in pycharm...

os.system("gnome-terminal -e 'bash -c \"sudo apt-get update; exec bash\"'")

leon332157 (345)

@K_log if u want to run a command u can use 'subprocess' module in Python, and doc and be found here:

jondkinney (5)

@K_log I'm pretty sure the original reply is what you want. It solved my problem. If you open the command pallet (F1 or right click in the code editor) then there is an option in the command pallet called "Open Shell". If you select that, then you'll have 3 splits to the right of your code editor one of which will be that bash terminal that you want where you can type "rails generate scaffold User". I just did this, it works. Hope this helps!

Carah29 (5)

@jondkinney i have tried this but am getting an error
bash:rails command not found