Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run cd command/change the folder path from ruby script

Tags:

bash

ruby

I am trying to run a command from ruby script. I got stuck in changing the folder path. Below is the command that I wrote. Can anyone let me know how to go ahead?

system("cd /home/user/Source/pxe/")

I want the terminal to point to the folder pxe when I run the ruby script. Is the code above correct? If not, can you let me know what the correct way is to call the cd command from ruby script?

like image 573
Rak Avatar asked Feb 16 '23 02:02

Rak


1 Answers

Do you want to change current directory for the script? Use Dir.chdir.

Dir.chdir('/home/user/Source/pxe')
like image 125
Sergio Tulentsev Avatar answered Mar 08 '23 13:03

Sergio Tulentsev