Hi, I'm experiencing an issue with creating an ftp session via cron.
I am creating an ftp session between a data server and a reporting tool. I have created the script wherein the data server begins the ftp session and puts files into the tool.
I have used the .netrc files for this and I run this command as root user
When I run the command manually (./script.sh), it works normally. It logs in and all files transfer properly. But when I make it a cron job (as root user), it fails and gives me an error "User cannot log in".
See below the .netrc and ftp batch script:
Ftp script:
My crontab entry is as follow:
Here's the output from the logs after being run on cron:
Hope you can help me on this.
Thanks!
Last edited by rbatte1; 07-14-2015 at 07:01 AM..
Reason: Wrapped output in CODE tags too
For sending commands in to run macros, that's excellent and I'm always happy to learn something new.
I can see that the job is run by root too from the output.
Just a stab, but as the profiles that normally set up the environment are not run, perhaps you need to set some yourself. The first one to consider would be HOME.
Can you display the default environment by running this with cron:-
Obviously don't post anything sensitive, but can you paste the content here (in CODE tags) or attach the files here?
For sending commands in to run macros, that's excellent and I'm always happy to learn something new.
I can see that the job is run by root too from the output.
Just a stab, but as the profiles that normally set up the environment are not run, perhaps you need to set some yourself. The first one to consider would be HOME.
Can you display the default environment by running this with cron:-
Obviously don't post anything sensitive, but can you paste the content here (in CODE tags) or attach the files here?
Robin
Thanks for replying, you can see the output below (users are changed to user1, user2 etc.)
I'm slightly confused by the value of variable HOME. You say that you are running as the root user, but the HOME value is set as /export/home/user1 Should the value not be the home directory of the root user? i.e. / or /root
I'm slightly confused by the value of variable HOME. You say that you are running as the root user, but the HOME value is set as /export/home/user1 Should the value not be the home directory of the root user? i.e. / or /root
Robin
Ahh yeah, it does. Hmm. Is there a way for me to change this? Although, I accessed the server via ssh using user1@host.ip then changing users via su so this could be the reason?
Also, would this affect the script running via cron as compared to running it manually?
Hi All , I want to use pipe in ftp session . Please let me know if there is any possibility
I have done FTP to a remote host with proper username and password
Now I want to take the latest file in a directory . The below is not workinf
ftp> ls -lrt |... (4 Replies)
Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered.
The script is as follow:
#!/bin/sh
for file in file_1.txt file_2.txt file_3.txt
do
awk '{ print "0" }' $file > tmp.tmp
mv tmp.tmp $file
done
And the cron... (2 Replies)
Hello,
I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me
1) How could I check my script when it is running from cron like... (3 Replies)
Hello everyone!
I am trying to log-in to a remote server over SSH, transfer file1 there, perform some checks, capture the results in file2 and transfer file2 back to my local server - all of this non-interactively. Initially, I tried to do this within a singe SSH session, using the following... (2 Replies)
Hi
Am logging in to the server as root.
Using the export EDITOR=vi option before editing the cron file
editing the crontab entry using crontab -e option
the additional jobs which i added can be seen immediately, but when i disconnect the session upruptly the cron entry vanishes the next time... (4 Replies)
Dears,
i want to execute unix commands through FTP session those commands like grep XXXXX file name > new file
tar new file
..... etc
Please let me know how to so
thank you (3 Replies)
In FTP session, how could know the present working directory in local machine? pwd command gives the present working directory for remote machine only. (2 Replies)
Hi
I am trying rename multiple files in a remote location by connecting through FTP. How do i do this? I get error as for is not FTP command. I looked the FAQ for scripting but it is doesnt relate to my post.
Please help. Thanks
ftp -in >Error.log <<!
open $HOST
user $User $Pwd
for... (2 Replies)
Is there any command which displays date while i am in a ftp session?
I tried the date command, but in vain
ftp> date
?Invalid command
ftp>
Can someone please help me. Thanks (2 Replies)
Hi guys,
i need to script the sending of multiple files through one ftp session. I have done this so far:
----------------------------------------------------------------
#!/bin/sh
USER=myuser
PASSWD=mypass
filenum=$1
x=0
ftp -n 159.167.95.199 <<SCRIPT
user $USER $PASSWD
binary
while ... (4 Replies)