LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-22-2007, 12:49 AM   #1
pinkygoyal
LQ Newbie
 
Registered: Nov 2007
Posts: 4

Rep: Reputation: 0
ftp upload script problem. please help


Hi All!

i wrote a script for upload files through ftp. but i am not able to tranfer the file.

Here is the script

#!/bin/bash
HOST='www.*****.com'
USER='****'
PASSWD='****'
FILE='abc.txt'
FILE2 ='ftpstatus.txt'
ftp -n -v $HOST << EOT
user $USER $PASSWD
prompt off
mput abc.txt ftpstatus.txt
bye
EOT
sleep 12

this script is running through cron job which sends the status of this file to my mail. Result i am getting into mail is :

Connected to www.******.com (**.**.**.**).
220---------- Welcome to Pure-FTPd [TLS] ----------
220-You are user number 4 of 50 allowed.
220-Local time is now 01:32. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 15 minutes of inactivity.
Remote system type is UNIX.
Using binary mode to transfer files.
331 User pinky OK. Password required
230-User pinky has group access to: backup
230 OK. Current restricted directory is /
Interactive mode off.
local: abc.txt remote: abc.txt
local: ftpstatus.txt remote: ftpstatus.txt
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.

can anyone figure out what's is going wrong in it ?????????
Please help me. it's very urgent.
Thnx in advance

Last edited by pinkygoyal; 11-22-2007 at 12:50 AM.
 
Old 11-22-2007, 07:12 AM   #2
pinkygoyal
LQ Newbie
 
Registered: Nov 2007
Posts: 4

Original Poster
Rep: Reputation: 0
if i use get command or ls command instead of put command this script works fine. but with put script don't transfer the files to ftp server.
 
Old 11-22-2007, 10:23 AM   #3
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
If you run the commands manually, instead of through the script, does the transfer take place?
Is there perhaps a permission problem or mismatch on the receiving directory?

This was normally how I developed such a script to ensure that I got it right and understood what was taking place, without any surprises.

PAix
 
Old 11-22-2007, 10:30 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
When cron runs, what is it's working directory? You may need to add some 'lcd's to your script. That would explain why gets and other commands work but puts don't.
--- rod.
 
Old 11-22-2007, 12:49 PM   #5
pinkygoyal
LQ Newbie
 
Registered: Nov 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Yes when i run through command line, i am able to transfer the file.
if there is any issue related to the permission i should not be able to transfer the file even by command line also.
 
Old 11-22-2007, 01:24 PM   #6
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
A problem with Cron is that it doesn't run in your normal environment, you have to carefully work at at ensuring dependencies you normally take forgranted are duplicated when Cron runs your script.
 
Old 11-22-2007, 09:28 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
As others have pointed out, when running from cron never use short names for anything and/or lcd into the relevant dir to put/mput files.
 
Old 02-15-2008, 02:48 PM   #8
lknds9r
LQ Newbie
 
Registered: Feb 2008
Posts: 1

Rep: Reputation: 0
need help to w/linux website upload-script error

fyi - I'm using go daddy's ftp client
2 questions - fyi - I'm using godaddy
1. keep having errors related to calendar.php file - if deltete calendar file - should remainder of website load to ftp server?

1 of 3 error reads:
main(calendar).php):failed to open stream: No such file or director in /home/content/on line 6

I don't know php code - what's the best way to fix script errors?
 
Old 02-15-2008, 03:20 PM   #9
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,211

Rep: Reputation: 293Reputation: 293Reputation: 293
Quote:
Originally Posted by pinkygoyal View Post
Yes when i run through command line, i am able to transfer the file.
if there is any issue related to the permission i should not be able to transfer the file even by command line also.
Make sure when using cron to put the full path to the file to be 'put', or 'cd' into that dir beforehand.

Cron has limited environment variables and PATH is one it doesn't usually have set unless you set it beforehand.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
buggy ftp upload script rblampain Programming 5 05-20-2007 12:30 AM
vsftpd non-annoy ftp cannot upload, mkdir problem sleepyhomme Linux - Server 2 04-29-2007 11:39 AM
Automating FTP upload via a shell script? Spitty Programming 5 01-16-2006 10:28 PM
Connection, login and upload files to ftp server via shell script Paulo Ges Linux - Networking 2 02-21-2004 01:01 PM
FTP upload problem: Error 550 Access Denied andrewstr Linux - Networking 0 12-17-2003 01:19 PM


All times are GMT -5. The time now is 11:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration