How to pass a variable to a system command in ruby?

In my ruby ​​script, I need to pass the path to the file system. For example, it’s like

system ("run.exe -l C: \"), where run.exe is my command, and -l defines the local path.

Now, if someone copies this to another machine drive C, you can change it to drive E.

So, I doubt how to do this as a variable or how to take the current folder path in this.

Any suggestions are welcome.

+4
source share
2 answers

mu is too short and Jan gives answers, but in general you can put ruby ​​commands in #{...} within "..." . In this case, you can do:

 system("fixed_string_1#{ruby_command_1}fixed_string_2#{ruby_command_2}fixed_string_3...") 
+3
source

Do you want to watch ARGF and ARGV

0
source

Source: https://habr.com/ru/post/1384178/


All Articles