Question

Here is my code

Net::SSH.start("XXX.upload.akamai.com", "sshacs", :keys=>["#{ENV['AKAMAI_SSH_KEY']}"]) do |mk|

channel = mk.open_channel do |ch|

ch.exec("rm filename.mp4") do |tk, success|

if success
    puts "++++++++++++ Deleted: #{success.class}"

else
    puts "------------ NOT deleted: #{success.class}"

end

end

end



end

success is always True eventhough the file I want to remove does not even exist!

What's going on??

Was it helpful?

Solution

From the Net::SSH docs for Channel#exec

In this case, success means that the command is being executed, not that it has completed,...

I'm wondering if you're getting success because it is successfully sending a request, and Net::SSH doesn't care if that request is complete or not. It did it's job, so it's a success.

combine it with something like: on data

channel.on_data do |ch, data|
  puts "what am i really getting back: #{data.inspect}" 
end

OTHER TIPS

I suppose to delete file you should use rm command. Like that

   ch.exec("rm filename.mp4") do |tk, success|
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top