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 Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
.netrc and ftp magikalpnoi AIX 4 07-07-2008 03:22 AM
.netrc file jithinravi UNIX for Dummies Questions & Answers 1 04-26-2007 06:01 AM
.netrc file grandtheftander UNIX for Dummies Questions & Answers 2 07-26-2006 12:10 PM
.netrc and ftp issue txdave UNIX for Dummies Questions & Answers 3 04-12-2005 11:32 PM
Help in .netrc edu_escandor UNIX for Dummies Questions & Answers 2 03-22-2005 07:12 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-17-2005
sveera sveera is offline
Registered User
  
 

Join Date: Mar 2005
Location: INDIA
Posts: 60
Red face using .netrc

Hi friends,
Can we use the file .netrc for automating ftp from a perl script ?
and if so then how do i go about it ?
can i have a sample script for this ?
thanks in advance
Veera
  #2 (permalink)  
Old 05-19-2005
chuckuykendall chuckuykendall is offline
Registered User
  
 

Join Date: Apr 2005
Location: McKinney, TX
Posts: 11
if you want to do this then make sure that you execute the shell's ftp command:

system ("ftp < ftp_script > ftp_log") and die "FTP failed:\n[$!]";
  #3 (permalink)  
Old 05-20-2005
sveera sveera is offline
Registered User
  
 

Join Date: Mar 2005
Location: INDIA
Posts: 60
Talking Perl ftp

Hi chuckuyKendall,
thanks for the reply.But for ftp in perl i am using the following command.
$ftp->put("$filename") or die "ftp failed";
how do i put the information into the logfile ?
i mean i want to have to info like 226 file transfer successfull , number of bytes transfered and things like that.
Can i add something to the above ftp statement so that i can direct the session out put to a log file ?
Please help
thanks in advance
Veera
  #4 (permalink)  
Old 05-20-2005
Lestat's Avatar
Lestat Lestat is offline
Registered User
  
 

Join Date: Feb 2005
Location: Quito - Ecuador
Posts: 67
Thumbs up Example of script

Hi, here i send u an example of auto ftp script that i use in one of our servers, i hope this script help you...

==========================================================

FECHA=` date '+%C%y%m%d'`
export FECHA

UNIDAD=10.3.8.105
USUARIO=ftp_user
CONTRASENA=ftp_user
REM_DIR=/usr/users/ftp_user
LOC_DIR=/backup_vol/Export
ACCION=mput
TIPO_ARCH=bi
LOC_FILE=*.dmp

REPORTS_USER_HOME=/usr/users/reports

LOG=${LOC_DIR}/transfer.${DATE}.log
ARCHIVOS_ERROR=${LOC_DIR}/archivos_error.${DATE}.log

FTPEADOS_FILE=${LOC_DIR}/ftpeados.${DATE}.log
SUPUESTOS_FILE=${LOC_DIR}/supuestos.${DATE}.log

NETRC=${REPORTS_USER_HOME}/.netrc

#Borra archivos de export antiguos
/usr/bin/rm -rf /$LOC_DIR/$LOC_FILE.Z
#
#Borra archivos de log antiguos

find /backup_vol/Export \( -name '*.log' \) -mtime +3 -exec rm -f {} \;

# Comprime archivos antes de ser transferidos.
/usr/bin/compress /$LOC_DIR/$LOC_FILE

# Creamos el .netrc para efectuar login automatico por ftp

echo "machine $UNIDAD" > $NETRC
echo "login $USUARIO" >>$NETRC
echo "password $CONTRASENA" >>$NETRC
echo "macdef init" >> $NETRC
echo "prompt" >> $NETRC
echo "mdelete $REM_DIR/$LOC_FILE.Z " >> $NETRC
echo "$TIPO_ARCH" >> $NETRC
echo "lcd $LOC_DIR" >> $NETRC
echo "cd $REM_DIR" >> $NETRC
echo "$ACCION $LOC_FILE.Z" >> $NETRC
echo "quit" >> $NETRC
echo "" >> $NETRC

chmod 600 $NETRC

ftp ${UNIDAD} >> ${LOG}

echo "*********************************************">>"$LOG"
echo " ">>"$LOG"
echo " TRANSFERENCIA HA FINALIZADO CON EXITO ">>"$LOG"
echo " ">>"$LOG"
echo "*********************************************">>"$LOG"

# Ejemplo de entrada a configurar en crontab
# Crontab entry
#
# Minuto Hora Dia_del_mes Mes Dia_de_la_semana comando
#
# 0 01 * * * /home/omni/scripts/auto-ftp/transfer.sh > /dev/null 2>&1
#

rm $NETRC
  #5 (permalink)  
Old 05-23-2005
sveera sveera is offline
Registered User
  
 

Join Date: Mar 2005
Location: INDIA
Posts: 60
Talking .netrc usage

Hi Lestat,
thanks alot for your reply.I shall use the code that you sent.
thanks for your valuable code.
Bye
Veera
  #6 (permalink)  
Old 05-23-2005
Lestat's Avatar
Lestat Lestat is offline
Registered User
  
 

Join Date: Feb 2005
Location: Quito - Ecuador
Posts: 67
No problem Veera, if u have any problem with the script just let me know, the variables are in spanish cuz i'm from south america but we cat work together to translate them... good luck, bye.
  #7 (permalink)  
Old 03-26-2008
terron79 terron79 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 3
Script .netrc

Hola Lestat:

Fijate que estoy tratando de ejecutar tu script para hacer en automatico la transferencia de unos archivos por ftp pero no me funciona, lo corro manualmente y se queda pensando y no hace nada. Podrķas ayudarme?

Gracias.
Sponsored Links
Closed Thread

Bookmarks

Tags
mtime

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 08:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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