FTP credentials from a config file


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP credentials from a config file
# 1  
FTP credentials from a config file

Hi,

I am using the following syntax to connect to an FTP server and paste the file.
Based on the value in the variable $Folder, i want to connect to different folders on the same server. The credential is different to access different folders. How to get the user name and password from a config file for each folder?

I dont want to Hard code the credentials in my shell script.

Folder= FolderA or FolderB.

ftp -pin $Test_host <<++
quote USER $USER
quote PASS $PASSW
cd $Folder
put $FILE.txt
bye
++


Thanks
Ashok
# 2  
Quote:
How to get the user name and password from a config file for each folder?
Depends on how your config file is!!!

Pls post sample input (both config and folder) and expected output.

Regards
Ravi
This User Gave Thanks to panyam For This Post:
# 3  
Hi,

Currently i have hardcoded the FTP user name and password in the script.

I did not use any config file.

Config file should have all the FTP user ids and password to access different folders on the same server.

Is it possible to use .netrc file? Can we have multiple user id and password for the same server in the file and select the user name and password based on the value in a variable?



Thanks
Ashok
# 4  
If the server is at a known, fixed IP address, you can assign it two names in /etc/hosts like this. Then either name will connect you to the same server.
Code:
192.168.1.21   serverA serverB

Then make a ~/.netrc file with both usernames and passwords. (Of course make sure ~/.netrc has file mode 0600.)
Code:
machine serverA login USERA password PASSA

machine serverB login USERB password PASSB

Then just access whichever server you want. The username and password will be handled automatically.

You may even be able to put macdef init in ~/.netrc for each server to change directories automatically. Though I'm not sure that works for every implementation.
This User Gave Thanks to KenJackson For This Post:
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #512
Difficulty: Medium
PHP requires that all variables begin with a dollar sign, for example $flag.
True or False?

10 More Discussions You Might Find Interesting

1. SCO

Config FTP on SCO Like proftpd

i have installed and working FTP Server With SCO 5.05. But i need solve problem related to config, like proftpd (i not have installed proftpd) the recomendation on client site is enable port 113 related to inetd. but i need solve it on server side, like proftpd.conf: DefaultRoot ~... (9 Replies)
Discussion started by: Arcanisgk
9 Replies

2. UNIX for Beginners Questions & Answers

How to check via SSH and credentials if file on remote server exists?

Hi there, I am sorry to ask that kind of beginner thing, but all the code I found online didnt work for me. All I want to do is: Check via SSH if a File exists on my webserver. The SSH login has to be with username and password. So I would be very thankful if somebody could write the line.... (8 Replies)
Discussion started by: Jens885544
8 Replies

3. UNIX for Advanced & Expert Users

Passing credentials via .netric file in Linux

How to create netrc file...I searched in google & got to know that we have to create .netrc file in home directory, I've created .netrc file in in home directory created .netrc file in home directory more .netrc machine $HOSTNAME login xxxx password xxxxx Note: echo $HOSTNAME... (2 Replies)
Discussion started by: sam@sam
2 Replies

4. AIX

Passing user/pass credentials to automountd map file.

How could I pass credentials to the automountd daemon through it's map files? Tried credentials=/some/file.txt - Didn't work. Tried SHARE.domain.com/user/pass/SHARE_NAME in map file - Didn't work Tried user=USER,pass=PASS - Didn't work. I can see the mounts created but when I access them... (4 Replies)
Discussion started by: Devyn
4 Replies

5. UNIX for Advanced & Expert Users

Need to pass credentials in one Go

Hi, We usually switch user using the below command. sudo su - user1 It then prompts for the password which we feed in. I wish to pass both the username and the password in one go thus eliminating the prompt for the password. I am using java standalone to connect to unix using... (11 Replies)
Discussion started by: mohtashims
11 Replies

6. Red Hat

Apache virtual host config vs global config problem

Hi folks, I am trying to configure Apache webserver and also a virtual host inside this webserver. For Global server config: /var/www/html/index.html For virtual host config: /var/www/virtual/index.html Both client10 & www10 are pointing to 192.168.122.10 IP address. BUT, MY... (1 Reply)
Discussion started by: freebird8z
1 Replies

7. Shell Programming and Scripting

Issues using array credentials to read contents of a file

Hi, I am trying to read the contents of a file using array credentials in unix. The file I am trying to read is tab separated and contains the below contents. # partnerid Direc Server Port Source_Dir Target_Dir Mask Remove Files Passwordless Compare Files ... (3 Replies)
Discussion started by: aartikara
3 Replies

8. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

9. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

10. IP Networking

RH 7.2 FTP Server Config

Is it possible to ftp from WinXp to a Linux box? I have the the ftp server set up to take the request from the WinXp box but each time I try to connect I keep getting an error, Connection established, unknown error(windows ftp program) or if I try to ftp from the DOS prompt I get ftp connect:... (3 Replies)
Discussion started by: flounder
3 Replies

Featured Tech Videos