1

I have three servers. I run a python script a.py in server1 and a.py will connect to server2 which has hadoop client. Then, from server2, I need to check if server3 has hadoop directory dir_eg or not.

How to do this in a.py?

fab -H server2 exe_cmd_in_server2:hadoop fs -mkdir server3/dur_eg is the command to create that dir, but I need check if it exists

display name
  • 4,165
  • 2
  • 27
  • 52
  • possible duplicate of [Test if File/Dir exists over SSH/Sudo in Python/Bash](http://stackoverflow.com/questions/17916144/test-if-file-dir-exists-over-ssh-sudo-in-python-bash) – l'L'l Dec 22 '14 at 22:45

1 Answers1

0

If you just want to avoid an error if the directory already exists you could use mkdir -p 'path'. If you want to know if the directory exists you can use fabric.contrib.files.exists.

tobltobs
  • 2,782
  • 1
  • 27
  • 33