Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

netrc file

Status
Not open for further replies.

salimwng

IS-IT--Management
Mar 11, 2002
134
MU

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 ?

Thanks
Salim
 
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.
 

Dear Ken,

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
 
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!!&quot;

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.

I hope this helps you achieve what you require.
 
From
Finally, ftp already has a scripting language built in to it. &quot;ncftp&quot; (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 &quot;puts&quot; a file.

With this in place, the command &quot;ftp somewhere.com&quot; will do the &quot;put&quot;. You could set &quot;prompt off&quot; and use &quot;mput&quot; or &quot;mget&quot; in the .netrc also.

The second just logs you in to &quot;someothermachine.org&quot; , turns on hash, etc. and then you can type your own commands.

You can fully script more complex things with:

#!/bin/ksh
echo &quot;machine somewhere.com login mylogin password mypass
macdef init&quot; > $HOME/.netrc
echo &quot;lcd /appl/fp/merge&quot; >> $HOME/.netrc
echo &quot;cd /appx/data/50/XFR/Data&quot; >> $HOME/.netrc
for i in *.tab
do
echo &quot;put $i ${i%tab}.dat&quot; >> $HOME/.netrc
done
echo &quot;quit&quot; >> $HOME/.netrc
echo &quot; &quot; >> $HOME/.netrc
# always end a macdef with a blank line
chmod 600 $HOME/.netrc
ftp somewhere.com


Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top