There is some script that takes time to archive files,

print 'Название файла, который архивируем: ' name_file = gets.chomp print 'Название архива: ' name_arch = gets.chomp #system('cd ') for i in 1..3 do system('time -o time.log tar -zcvf '+name_arch+'.tar.gz '+name_file) f = File.open("time.log", 'r') while line = f.gets if line.grep /^(real + \d)/ File.open('table.log', 'a') puts line end f.close end end 

But at startup, after specifying the name of the archive and file, tar says:

 Название файла, который архивируем: *.klk Название архива: q tar: *.klk: Функция stat завершилась с ошибкой: Нет такого файла или каталога tar: Завершение работы с состоянием неисправности из-за возникших ошибок 

However, when writing the same command with the same parameters, it makes everything go smoothly. Actually, why does the archiver behave this way? PS script is in the same folder with the file

    1 answer 1

    For the processing of regular expressions of arguments in the command line is your little shell, bash for example.

     $ echo *.log java_error_in_PYCHARM_2538.log java_error_in_PYCHARM_5336.log pgadmin.log replay_pid2538.log $ echo * ***ТУТ МНОГО-МНОГО ФАЙЛОВ***` 

    When you run the system command, *.klk not expanded into a list of files, but is transmitted directly, as if *.klk is a file.

    Try writing this:

     system('/bin/bash -c "time -o time.log tar -zcvf '+name_arch+'.tar.gz '+name_file + '"')` 

    Instead of /bin/bash you can put any other path to the shell. You can find it by running the which command in the terminal:

     $ which bash /bin/bash $ which fish /usr/bin/fish $ which sh /bin/sh 
    • Replaced with your line. Without changes. In fact, it looks like the same thing. Even considering that *.klk perceived as a separate file. Considering that he does not even find by the explicit name exmpl.klk . system , as far as I understand, and so it outputs to /bin/bash appending its variables to the command (if necessary). Or I'm wrong? - QWD666
    • , And the working directory at you is precisely specified? And what if you try the full path? /home/QWD/myfiles/file.klk , for example - Alexander Zinin
    • /home/eve/script.rb ; /home/eve/file.klk file; tar itself swears when you type tar -zcvf exmpl.tar.gz /home/eve/file.klk To do this, the code commented out the transition to the file via cd - QWD666
    • I tried to run the script on my own - everything works: [ pastebin.com/6VkExJEH ]( pastebin) - Alexander Zinin
    • It's all over. It turns out that the built-in launch in RubyMine came from the /tmp/script.rb folder and in the end it could not do anything. But why he did not do this with the transition to the folder - a mystery. Thank you!) - QWD666