The netrc file is normally used by ftp. Could anybody help me where should i create this file ( in users directory or main root directory ? ). Cna i use vi for creatins this file ?
What commands or scripts are normally present in it ?
It's always worth doing a search in these forums. Hopefully thread60-38539 will give you your answer, though I should add that this is for Solaris. HTH.
Thanks a lot i've got the info. Though i search the netrc in search engine i did not obtain any reply. Can't figure this out....
In fact the reason i wanted info about the netrc file is because i wanted to automate the ftp to copy a group of directories from one Unix server to another Unix server ( same version , same domain name ) via tcp/ip.
I looked for "Automating ftp" on the tek-tips , but could find any info relating to transfering directories and sub directories ( with the contents present ). Could you please help me out if possible on this issue.
Operating system i am using is SCO Unix 3.2.4.2
Thanks a lot for your help and the precious time given to help sort out my problem.
Regards.
Salim
no problem. I can't imagine why your search isn't working. However, the following is taken from rajeshrcmc's post in the above thread:
"Hi !
You can also try creating a .netrc file in the users homedirectory ,a template of .netrc is as follows
machine <hostname> login <loginid> password <passwd>
macdef init
bin
put filename1 filename2
...
bye
endmac
<blank line>
After creating the .netrc in the users homedirectory ,
just say
$ ftp <hostname>
The ftp happens automatically ,
I have tried this on AIX , i am not sure on solaris!!"
As far as transferring directories and sub-directories, you might like to consider tarring them up and transferring the tar file by ftp, untarring them at the other end.
Finally, ftp already has a scripting language built in to it. "ncftp" (available from Skunkware) has even more capability, but here's a basic .netrc (see man netrc) for normal ftp.
----$HOME/.netrc 600 perms --
machine somewhere.com login mylogin password mypass macdef
init
lcd /appl/fp/merge
cd /appx/data/50/XFR/Data
put artrx.tab TRXFER.dat
quit
machine someothermachine.org login whatever password pass macdef
init
hash
bin
prompt off
machine yetanother ...
The first example (somewhere.com) logs in, changes to a local directory /appl/fp/merge, then changes to /appx/data/50/XFR/Data on the server and "puts" a file.
With this in place, the command "ftp somewhere.com" will do the "put". You could set "prompt off" and use "mput" or "mget" in the .netrc also.
The second just logs you in to "someothermachine.org" , turns on hash, etc. and then you can type your own commands.
You can fully script more complex things with:
#!/bin/ksh
echo "machine somewhere.com login mylogin password mypass
macdef init" > $HOME/.netrc
echo "lcd /appl/fp/merge" >> $HOME/.netrc
echo "cd /appx/data/50/XFR/Data" >> $HOME/.netrc
for i in *.tab
do
echo "put $i ${i%tab}.dat" >> $HOME/.netrc
done
echo "quit" >> $HOME/.netrc
echo " " >> $HOME/.netrc
# always end a macdef with a blank line
chmod 600 $HOME/.netrc
ftp somewhere.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.