main file configuration


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting main file configuration
# 1  
Old 11-02-2011
main file configuration

I was writing a script that will FTP files to destination folder. All configuration should be done through a properties files and the main script will read the values from the properties file.

the properties file should contain
1) Source folders
2) Source file pattern
3) Destination folder
4) User id
5)remote server url

I have created the structure of the properties file also and the name of the property file would be archieve1.config


Code:
#remoteurl of the machine 
Remoteurl=sfy.waly.com

# your user id 
userid=youruserid


#This is the source directoy from where the files will be picked up
SrcFolders=/home/Administrator/files


#This directory path should end with a slash(/)
DestFolder=/home/Administrator/output/


#the pattern of the files
SourcefilePattern=*.txt

and now the command for sftp which I was using earlier without use of property file was..
Code:
sftp username@host <<EOF
lcd /home/dirA
cd /home/dirB
mput *.txt
exit

Thi above script works perfect and ftp the files from one folder to another within the same server but now I want to make a seprate main script file that will read the properites files as shown above that is from archieve1.config and nothing will be hard coded like username would be read from properties file etc and will sftp files from one folder to another within that server , so how would be the main script file ..please guide me..!!
# 2  
Old 11-02-2011
main.sh
Code:
#!/bin/ksh

. /path/to/archieve1.config

echo "Remoteurl->[${Remoteurl}]
....

# 3  
Old 11-02-2011
Quote:
Originally Posted by vgersh99
main.sh
Code:
#!/bin/ksh

. /path/to/archieve1.config

echo "Remoteurl->[${Remoteurl}]

...
Hi,

so the main script file would include the properties file lyk this way...shown below..
Code:
#!/bin/ksh
. /path/to/archieve1.config
sftp $userid@$Remoteurl <<EOF
lcd /home/dirA cd /home/dirB mput *.txt exit

Is this the correct way in the main script file...if something wrong then please guide me...!!
# 4  
Old 11-02-2011
This is bumping/double posting...
Thread closed, continue here:
https://www.unix.com/shell-programmin...in-server.html
# 5  
Old 11-02-2011
Quote:
Originally Posted by rahulsxn660
Hi,

so the main script file would include the properties file lyk this way...shown below..
Code:
#!/bin/ksh
. /path/to/archieve1.config
sftp $userid@$Remoteurl <<EOF
lcd /home/dirA cd /home/dirB mput *.txt exit

Is this the correct way in the main script file...if something wrong then please guide me...!!
something like that - just replace any hardwired references with the variable you define in your config file AND try it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Retrieving the relevant search from search file in the main file

I have two files: file 1: hello.com neo.com,japan.com,example.com news.net xyz.com, telecom.net, highlands.net, software.com example2.com earth.net, abc.gov.uk file 2: neo.com example.com abc.gov.uk file 2 are the search keys to search in file 1 if any of the search... (7 Replies)
Discussion started by: csim_mohan
7 Replies

2. Shell Programming and Scripting

Adding header to sub files after splitting the main file using AWK

Hi Folks, I have a file like: mainfile.txt: ------------- file1 abc def xyz file1 aaa pqr xyz file2 lmn ghi xyz file2 bbb tuv xyz I need output having two files file1 and file2. file1: ------ Name State Country abc def xyz aaa pqr xyz file2: (3 Replies)
Discussion started by: tanmay.gemini
3 Replies

3. Shell Programming and Scripting

configuration for ftp script in main script

Hi, I am new to shell scripting,and i was planning to write a script that will FTP files to destination folder. I was planning that All configuration should be done through a properties files. and finally the output should be Files are transferred I have developed a properties file named... (4 Replies)
Discussion started by: rahul125
4 Replies

4. Shell Programming and Scripting

writing the main script file

Hi, I am new to shell scripting,and i was planning to write a script that will move files which have a datetime >= currentdate-N from a source to destination folder. All configuration should be done through a properties files. Here the value of N should be taken as 10 days(modification... (6 Replies)
Discussion started by: rahul125
6 Replies

5. Shell Programming and Scripting

Delete one Line from Main File and Create another

Hi I need to write a script which will search for some text in some CSV files and will delete the record/line with the matching text and will insert that record/line into some other file. Can you please help? Here is what I want: - Contents of MainFile.csv: - 1,2,3,Loan,4,5,6... (3 Replies)
Discussion started by: kapilk
3 Replies

6. Shell Programming and Scripting

Configuration File

Hi I need a cofiguration file for my perl script... Suppose my perl script for counting total number of user is #!/usr/bin/perl -w $total_users; #To get how many users currently logged in########### $total_users=`who | wc -l`; print... (2 Replies)
Discussion started by: Harikrishna
2 Replies

7. Solaris

configuration file

Hi all-interesting forum. I am new with Solaris and i would like your advice on this: I am using a solaris 8 (ultra sparc IIi) workstation at my work,and i am trying to built another one exactly the same-so if the first one fails to have another one as backup. The problem is that the guy who... (1 Reply)
Discussion started by: ioa_pol
1 Replies

8. Shell Programming and Scripting

configuration file

i am trying to use a configuration file to FTP some files.. i am not sure how to call or use a configuration file in script. can anybody help (5 Replies)
Discussion started by: iamcool
5 Replies

9. UNIX for Dummies Questions & Answers

Main UNIX file?

I am restoring data off of a backup tape onto a server I have. The data is coming from an old server I used to have, different IP and different Name. I want to transfer ALL the data from the tape, but yet not have any of my unix network configurations or name settings (on the server itself) to... (3 Replies)
Discussion started by: HandleX
3 Replies

10. Shell Programming and Scripting

Extracting data from text file based on configuration set in config file

Hi , a:) i have configuration file with pattren <Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output> eg: myfile.confg 9899000000,9899999999,DATA,b.dat 9899000000,9899999999,SMS,a.dat b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies
Login or Register to Ask a Question