I have a file located on my linux box that is generated by a python script, the file is dropped inside of the /root/ directory
My bash script looks like so:
#!/bin/bash # Run the HR Data feed cd /root/hr-feed # the file created here will land one directory above the scripts in /root/ python main.py # Transfer the file to the server cd /root/ smbclient \\\\[SERVER]\\[SHARE] --workgroup=[WRKGRP] --user=[USR] [PASS] -c 'put HRDataFeed.txt'
Everything works as desired up to the last line. It must be executing with an error (though I'm not quite sure how to figure out what that error might be).
This job is running from the crontab. Which as I understand runs in a slightly different environment than root (or at least it seems to with how it behaves).
If I execute the script directly (not from the crontab) it runs without a hitch and the file is transferred to the destination windows server box. My guess is that maybe I need to supply the full path to the HRDataFeed.txt file as part of the put command; however, I cannot seem to figure that out.
smbclient .... -c "put /root/HRDataFeed.txt"
results in an error that the file /root/HRDataFeed.txt cannot be found.
Any input is greatly appreciated.
I tried updating my crontab to read (for the sake of testing i had it running every minute)
- /root/hrdatafeed > last_run.txt
However nothing ever seemed to land in the file.
I will try just adding a pipe directly to the SMBClient command.