The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
scp automated script gholdbhurg UNIX for Advanced & Expert Users 5 10-27-2008 01:23 AM
Automated shtudown joe1967 Shell Programming and Scripting 5 05-29-2007 08:04 PM
automated ftp. sangfroid Shell Programming and Scripting 10 05-07-2007 11:52 AM
Automated FTP shauche UNIX for Advanced & Expert Users 11 07-11-2002 02:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-09-2001
n9ninchd n9ninchd is offline
Registered User
  
 

Join Date: May 2001
Location: Bay Area
Posts: 25
If I wanted a machine to put a specific file onto another OS far across the internet via FTP - and I wanted to do it automatically not user intervented, how would I do that?

Use the PUT command?

The file name and position never changes, it gets overwritten and the system on the other end takes care of all the dirty work. I just need the unix server to FTP that one file.
  #2 (permalink)  
Old 05-09-2001
mib mib is offline
Registered User
  
 

Join Date: Jan 2001
Location: Calicut
Posts: 228
You can create a file called ".netrc" in your home directory. Put these line in .netrc file:

machine servername login username password passwordhere

When it's done, create a file (we will call it "ftpcommands")
that contains the commands. For example:

cd /ftp/directory
put yourfile
bye

and call it:
# ftp servername < ftpcommands

or

#!/bin/bash
#autoftp.sh
ftp machine < ftpcommand

# ./autoftp.sh

Note: chmod 400 .netrc

You can also use "expect". man expect for more info


HTH
  #3 (permalink)  
Old 05-10-2001
n9ninchd n9ninchd is offline
Registered User
  
 

Join Date: May 2001
Location: Bay Area
Posts: 25
Slight Variation

I keep getting these requests, driven me nuts.
Now I need to be able to put a variable. Variables do not get handed off well to the FTP process commands.
Any ideas?

Example: I wanna put this command in place

put $1.backup.file

FTP is not pulling the filename correctly - I get cannot find file $1.backup.file


  #4 (permalink)  
Old 05-11-2001
mib mib is offline
Registered User
  
 

Join Date: Jan 2001
Location: Calicut
Posts: 228
#!/bin/bash
#autoftp.sh
# use "\n" to seperate entry
# and use binary instead ascii if you think

FTPCommand="cd FTPdirectory\nascii\nput $1.backup.file\nbye"
echo -e $FTPCommand | ftp machine
echo "$1 Ftp'd to machinename"

and run this script to ftp "today.backup.file"

# ./autoftp today

Be sure to include full path if "today.backup.file" file is not in the directoy from where you execute the script.


HTH

[Edited by mib on 05-11-2001 at 07:29 AM]
  #5 (permalink)  
Old 05-11-2001
kornshellmaven kornshellmaven is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 25
We use variations on the following script all over the place. We designed an "FTP server" written in korn shell to handle ALL FTP's between different platforms aw well as our corporate "Enterprise FTP server (Sterling Mailbox)

All variables are defined before invoking the FTP. (Currently in a flat file - soon to be in a DB table)


Contents of DYNAM_FTP.KSH:
#!/etc/usr/ksh
assorted variable assignments
ftp -n -v $HOSTNAME <<-END
user $USERID $PASSWORD
cd $SRC_DIR
lcd $TARGET_DIR
pwd
get $SRC_FILE
END


The above "here document" is dynamically built based on a control record which specifies source info (IP, id, password, filename, etc.)
External to the above:
chmod +x DYNAM_FTP.KSH
DYNAM_FTP.KSH to invoke
We capture the output of the above to a file and then grep for various errors....

[Edited by kornshellmaven on 05-12-2001 at 06:58 PM]
  #6 (permalink)  
Old 05-16-2001
n9ninchd n9ninchd is offline
Registered User
  
 

Join Date: May 2001
Location: Bay Area
Posts: 25
Well - tried it, and even with that it still trys to put those IDs in instead of a variable

example

cd $Src_Dir

It trys to change to a directory /$Src_Dir

Don't work - any other ideas?

Solaris 7
  #7 (permalink)  
Old 05-18-2001
kornshellmaven kornshellmaven is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 25
Lightbulb

Not sure why it's not expanding the variables within the here-document - Turn xtrace on to see commands echoed back

The following works fine
#!/usr/bin/ksh -x
DATA=$AL_DATA
ftp -n -v slapdev <<-END
user userid password
pwd
cd $DATA
pwd
END
It doesn't matter if I cd to $DATA or $AL_DATA (exported variable)- it gets expanded OK

We also have routines to build the FTP here-doc dynamically
exec 4>dynam_ftp.sh
print -u4 "#!/usr/bin/ksh -x"
print -u4 "ftp -v -n $DEST <<-END"
print -u4 "user $USER $PASSWORD"
print -u4 "cd $DATA"
print -u4 "pwd"
print -u4 "lcd $SRC_DIR"
print -u4 "mget $FILE_PATTERN"
print -u4 "END"

chmod +x dynam_ftp.sh
dynam_ftp.sh

The contents of the dynam_ftp.sh file will have the fully expanded variable values. The above might be a little overkill for your needs.

We're running Solaris 7 as well
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0