Results 1 to 10 of 13
Hi,
I am trying to write some shell scripts to automate a task. This is my first attempt at doing this. What I want to do is have 2 scripts, ...
- 07-17-2009 #1Just Joined!
- Join Date
- Apr 2008
- Location
- Chicago, IL
- Posts
- 34
Noob stuck writing FTP scripts
Hi,
I am trying to write some shell scripts to automate a task. This is my first attempt at doing this. What I want to do is have 2 scripts, the first script is to create a directory using the current date and copy the files from the ftp script.
Here is my first script
ftpstartup.sh
#!/bin/sh
Today="`date +%m%d`"
mkdir /home/***checkout/$Today
cp * /home/***checkout/$Today
ftp < autoftp.sh
and the next script is the ftp script autoftp.sh
#!/bin/bash
open 10.1.2.235
username
password
cd /home/carsids/garyftp/***checkout
get Patron.csv
get GroupCRS.csv
get GroupMemb.csv
bye
The problem is the ftp script, it doesn't recognize the username line or beyond.
Does anyone have any advice as to where my mistake is?
I am running CentOS 5.3.
- 07-17-2009 #2
Put authentication stuff in your .netrc file.
- 07-20-2009 #3Just Joined!
- Join Date
- Jul 2009
- Posts
- 58
I'm surprised it's accepting the hostname.
I would think you need to do something like this:
for it to even have a chance of working. I don't think it will though.Code:foo=`autoftp.sh` eval ftp -n ${foo} in the second script, everything has to be an "echo" echo "quote USER $USER" echo "quote PASS $PASSWD" ... exit 0
- 07-20-2009 #4Just Joined!
- Join Date
- Apr 2008
- Location
- Chicago, IL
- Posts
- 34
Still stuck, another SFN question
I cannot locate the .netrc file anywhere in the file tree. What is the pathway?
I do apologize for the dumb questions, but I have never written anything like this before.
- 07-20-2009 #5Linux Guru
- Join Date
- Nov 2007
- Posts
- 1,695
Google: bash ftp script => One of many links
- 07-20-2009 #6
You have to create .netrc file in your home directory.
netrc(5): user config for ftp - Linux man page
Other programs read this file too, e.g. wget.
- 07-21-2009 #7Just Joined!
- Join Date
- Apr 2008
- Location
- Chicago, IL
- Posts
- 34
Thank you to Segfault, HROAdmin26, and aram535. I still cannot get the username and password to populate using a script. I don't know how to do this, and all of your efforts have helped, but I don't have the skills to get it done.
Can anyone point me in a specific direction as to how I can get this to work? I am frustrated and everything I have read is telling me something different and none of the solutions I have tried have come close to working.
Performing a Google search of ftp bash script gives me information overload. Does anyone out there know of a book I can maybe find that can help?
- 07-21-2009 #8This is the simplest .netrc file, make sure it has -rw------- permisssions. With this one can log into ftp.funet.fi without giving username and password. (Both username and password are ftp in this case.)Code:
machine ftp.funet.fi login ftp password ftp
- 07-22-2009 #9Just Joined!
- Join Date
- Apr 2008
- Location
- Chicago, IL
- Posts
- 34
Just about ready to give up...
thanks Segfault,
that .netrc file worked, but it isn't working for the project I am stuck on.
I need the login and password to be sent from the .netrc file to the ftp server, but it isn't working.
I don't know what I'm doing and I can't find enough documentation to help me get there. Here is where I'm stuck.
autoftp.sh
for the .netrc I haveCode:#!/bin/sh ftp 10.1.2.235 username password cd /home/ca/gftp/wco get file1 get file2 get file 3 bye
I am sorry to keep bugging people about this, but I am clueless and I feel like I'm learning less than more as I struggle with this simple task.Code:machine 10.1.2.235 default login username password password login username password password
J (completely lost and confused noob)
- 07-22-2009 #10
Hang in there buddy, you'll get it right. This isn't Schoolwork is it?
I do not respond to private messages asking for Linux help, Please keep it on the forums only.
All new users please read this.** Forum FAQS. ** Adopt an unanswered post.


Reply With Quote
