I’m writing a ruby script that will automate backing up my laptop to my ssh server. I seem to be stuck on a system call though.
$x = "C:\\Program Files\\7-Zip\\7z.exe"
###calibre library###
$library = "C:\\Users\\maste_000\\Documents\\Calibre Library"
system($x, "a library.7z", $library, " -r")
I’m trying to call the exe 7z and create a file called library.7z, from the directory pointed to by $library. No matter how I arrange this though I keep getting a 7z command error. I’m assuming this has something to do with how I’m performing the system call though.
I’d guess that you want this:
That would give you the same effect as this at the command prompt:
Assuming, of course, that I haven’t completely forgotten how quoting works with the Windows command line.
The space in
$librarywon’t matter when you use the multi-argument form of thesystem; part of the reason that you use this version ofsystemis to avoid all the weird quoting that you need when the shell is in the way. The main thing is that you probably need to separate'a'and'library.7z'so that they are two arguments rather a single argument with a space as the second character; without that separation you’d be saying this:and that doesn’t look right.