My code:
df = read(`df -h|grep /dev/sda1 && df -h|grep pCloud`, String)
When I run it I get the following message from Julia:
Warning: special characters "#{}()[]<>|&*?~;" should now be quoted in commands
│ caller = #shell_parse#333(::String, ::Function, ::String, ::Bool) at shell.jl:100
└ @ Base ./shell.jl:100
df: invalid option -- '|'
Try 'df --help' for more information.
ERROR: LoadError: failed
process: Process(`df '-h|grep' /dev/sda1 '&&' df '-h|grep' pCloud`, ProcessExited(1)) [1]
I have found someone having a similar problem, but they seem to have resolved this issue without escaping.
Not all escapism is bad for you. It is important to identify why you need to escape. If you are running away from reality then the consequences are not likely to be good. But if you are accessing another world in order to gain some insights to bring you back to this one – well, that IS good.
Julia commands are not run in a shell, so using shell features like that will not work. If you want to pipe from one command to another, you should use the pipeline
function and if you want to test the success or failure of a command or pipeline, run it with the success
function. In this case, you could do this:
success(pipeline(`df -h`, `grep /dev/sda1`)) &&
success(pipeline(`df -h`, `grep pCloud `))
Of course, in that case you could call df -h
a single time and do
df = read(`df -h`, String)
contains(df, "/dev/sda1") && contains(df, "pCloud")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With