When I run the code yesterday I am getting output,when I run same code today I am getting error?

If run the below code today its creating all directory and getting output files,I f run same code tomorrow I am getting error.
can any one give suggestion to sortout this error.

OSError:[ERRor 2] no such file or directory : '062518'

My code looks like this

import paramiko
import sys 
import os 
from datetime import datetime
import time
list_of_hosts = {"10.200.3.444": ["command1","command2"]}   
lis_of_dirs = ["/ooo/SSS/SSSS/data/Capture/AA/","/ooo/SSS/SSSS/data/Capture/BB/"]
for host in list_of_hosts:
ssh = paramiko.SSHClient()  
ssh.load_system_host_keys()  
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())  
ssh.connect('%s' % host,username='xxxxx',key_filename='path')
ssh_con = ssh.invoke_shell() 
print("SSH connection to %s established" % host)
commands = list_of_hosts[host]  

for command in commands:
    stdin, stdout, stderr = ssh.exec_command(command)
    time.sleep(10)
    console_output = (stdout.read())

    print("\n Console OutPut:", console_output)

    for dirs in lis_of_dirs:
        os.chdir(dirs)
        date_dir = datetime.today().strftime('%d%m%y')
        if os.path.isdir(host):
            if os.path.isdir(date_dir):
                os.chdir(date_dir)
                with open(command, 'w') as f:
                    f.write(console_output)
            else:
                os.chdir(host)
                os.chdir(date_dir)
                with open(command, 'w') as f:
                    f.write(console_output)

        else:
            os.makedirs(host)
            os.chdir(host)
            os.makedirs(date_dir)
            os.chdir(date_dir)
            with open(command, 'w') as f:
                 ssh.close()

Hey - where did you buy your crystal ball? I really would like to know in advance when my code is going to work, and when it will fail.

Does that directory 062518 exist?
And, are you sure the error message comes from above code snippet? 062518 does not correspond to the strftime format string %d%m%y . . .

Not exist... Error says no such file or directory

So - create it and it will run.

Strftime('%m%d%y')

I am giving like this
When I am trying to create date folder getting error.

Not in above code snippet. On top, watch your syntax.

Pls check the entire path for existence and permissions.

Hi haribabu2229...

Satisfy my curiosity, I am assuming this is Python 3.x.x code.
if it is then how did you get this section to work at all without a major traceback error?

for host in list_of_hosts:
ssh = paramiko.SSHClient()  
ssh.load_system_host_keys()  
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())  
ssh.connect('%s' % host,username='xxxxx',key_filename='path')
ssh_con = ssh.invoke_shell() 
print("SSH connection to %s established" % host)
commands = list_of_hosts[host]  

I am using python 2.x.x
I got the solution the error which I got

---------- Post updated at 11:54 AM ---------- Previous update was at 11:50 AM ----------

Always debug the code step by step to catch the loophole

Debug on what? Python tracebacks are ridiculously accurate and would point out any syntax AND some programming errors, so......
You can't possibly be using Python 2.x.x as you are using print functions NOT print statements, print("\n Console OutPut:", console_output) , AND, your first for loop, for host in list_of_hosts: , has no indented code to work on which causes a script crash, so again how did you get it to work?