using .netrc


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users using .netrc
# 1  
Old 05-17-2005
Power 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  
Old 05-19-2005
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  
Old 05-20-2005
Computer 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  
Old 05-20-2005
MySQL 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  
Old 05-23-2005
Computer .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  
Old 05-23-2005
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  
Old 03-26-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with macdef (.netrc)

Am trying a shell script for ftp process on Solaris I am trying to mget files to Destination server: myserverxxx1 folder : /backup/dumps/SERVER-1backup/afterbatch From Source server: SERVER-1 folder : /dumps/daily/backupafterbatch/Thu21Oct_04:22:37 depending on the date the... (1 Reply)
Discussion started by: sunnyboy
1 Replies

2. IP Networking

Can I use 2 different id's in .netrc for same dest. machine.

I have 2 different id's for an ftp destination. Each id handles files differently on the destinations end. Is it possible to have one destination machine and assign an alias name for each id. The .netrc file doesn't allow this. (2 Replies)
Discussion started by: wangotango
2 Replies

3. Red Hat

Netrc for Linux

What is the proper format for configuring the netrc file for linux. On Solaris it was: Machine <machinename> login Domain\\login password passwordname (1 Reply)
Discussion started by: soupbone38
1 Replies

4. Shell Programming and Scripting

FTP/nmap/.netrc

So... I'm trying to script and FTP Backup of some files from openVMS Alpha machine to a Unixware 7 machine. I decided to use .netrc to do all the FTP actions however when I send the nmap command. It pretty much gets ignored while even other things such "ascii", "case" etc.. get respected... (0 Replies)
Discussion started by: thesubmitter
0 Replies

5. UNIX for Dummies Questions & Answers

Multiple macdefs in .netrc

Hi this is about using .netrc with multiple macro definitions for a single target server. I have seen this done successfully before, but am having trouble getting it working here. my .netrc file is like the following: machine server1 login userid1 password userpwd1 macdef... (1 Reply)
Discussion started by: PSDba
1 Replies

6. AIX

.netrc and ftp

Hello all, I am using a .netrc to automatically access an ftp host. Here is the line I use... machine 412.blank.com login nw\mylogin password ******* when I use this command... ftp 412.blank.com I get... Connected to 412.blank.com. 220 server_7 FTP server (EMC-SNAS: 5.5.25.2)... (4 Replies)
Discussion started by: magikalpnoi
4 Replies

7. UNIX for Dummies Questions & Answers

.netrc file

I had configured the .netrc file for automatic login to ftp however i am not clear how to give the port no after the "machine" token: as in, when i give machine xyz.com 2121 login <usid> password <pass> i am getting the error Unknown .netrc keyword 2121 while giving the command ftp xyz.com... (1 Reply)
Discussion started by: jithinravi
1 Replies

8. UNIX for Dummies Questions & Answers

.netrc file

hello, I am trying to write an automated script to transfer multiple files to another solaris 5.8 box. I am using the #! /bin/bash prompt and I am having trouble finding/creating the .netrc login file. I googled and the only info I got was that I should create/find it in my home directory. I went... (2 Replies)
Discussion started by: grandtheftander
2 Replies

9. UNIX for Dummies Questions & Answers

Help in .netrc

Hi, I would like to ask if the .netrc file should really be stored/placed in the /home/<userid> directory or in the home directory indicated by the uinfo command? I am currently having problems with a .netrc file which is owned by a id which has it's home directory pointed to a... (2 Replies)
Discussion started by: edu_escandor
2 Replies

10. Shell Programming and Scripting

.netrc question

Hi, id like to ask a question about .netrc. Id like to have 2 entries for a particular machine, but with different ftp userid's ie machine 172.19.8.26 login dcm password dcm macdef job1 bin hash bye machine 172.19.8.26 login ppp password ppp macdef job2 bin hash bye this code DOES... (8 Replies)
Discussion started by: hcclnoodles
8 Replies
Login or Register to Ask a Question