1752754 Members
4497 Online
108789 Solutions
New Discussion юеВ

Re: run script

 
SOLVED
Go to solution
heaman1
Regular Advisor

run script

I have two scripts ( eg. ftp_script 1 , ftp_script2 ) that use ftp to login a server ( eg. 192.168.0.3 ) to download file , I use .netrc to control the password , the user is no need to input login/password to server now ,

however , ftp_script1 & ftp_script2 doing different things so I want to use different login/password when use these script ( eg. ftp_script1 use login ID: userA , password: passwordB while ftp_script2 use login ID: userB , password: passwordB ) , if I add these two login/password to .netrc , how to tell the script to use right login/password ? thx


machine 192.168.0.3 login userA passwd passwordA
machine 192.168.0.3 login userB passwd passwordB
10 REPLIES 10
Dennis Handly
Acclaimed Contributor

Re: run script

>I use .netrc to control the password
>I want to use different login/password when use these script

I suppose you could use an IP alias for the machine so you can have different "machine" entries in your .netrc.

Or you could change $HOME and point to different directories with the two .netrc files.
Ganesan R
Honored Contributor

Re: run script

Hi Heaman,

Why don't you run these two scripts with two different local users? So that both users have it's own .netrc file.

You can use userA in one .netrc file and userB in another .netrc file.

The other option is, as Dennis said, you could use if the server has another virtual ip.

Best wishes,

Ganesh.
heaman1
Regular Advisor

Re: run script

thx replies ,

You suggested use IP alias , virtual IP , can give the advice how to do it ? thx
Ganesan R
Honored Contributor

Re: run script

Hi,

You first check if the remote server has virtual ip or not using netstat -in command.

If it does not have, then you can configure virtual ip on the same interface. Use sam and add logical interface option in the network configuration.
Best wishes,

Ganesh.
heaman1
Regular Advisor

Re: run script

thx replie ,

the remote is not owned by us , we can't change anything , is there any other method ? thx
heaman1
Regular Advisor

Re: run script

I mean the remote server is not owned by us , we do not hv permission to change anything. thx


Ganesan R
Honored Contributor
Solution

Re: run script

Hi Heaman1,

In that case try this. Hopefully it should work.

1.Add a host entry in your local /etc/hosts file for 192.168.0.3 like below

192.168.0.3 ftpserver

2.Next modify your .netrc file like this.

machine 192.168.0.3 login userA passwd passwordA
machine ftpserver login userB passwd passwordB

3.In your second script modify all the ipaddress with hostname ftpserver. Now, when the first script runs it will refer the first entry in your .netrc file. When the second script runs it will refer the second entry in your .netrc file.

But you should understand one thing that, when first script runs it is going to login to userA home directory and fetch the file. Same way, when second script runs it is going to login to userB home directory and fetch the file. You should make sure that the files are available on respective directories.

Hope this helps you.

Best wishes,

Ganesh.
Ganesan R
Honored Contributor

Re: run script

Hi Heaman,

Any update on this? Have you tried and tested?
Best wishes,

Ganesh.
heaman1
Regular Advisor

Re: run script

thx Ganesan R ,

it works , really excellent and fantastic solution .