Sponsored Content
Full Discussion: Read a control file
Top Forums Shell Programming and Scripting Read a control file Post 302896423 by samrat dutta on Monday 7th of April 2014 01:23:27 PM
Old 04-07-2014
Read a control file

Hi I have the below .sh script which receives a argument ftpClient=$1 . This argument i am trying to read from a control file called ftpProperties.control.
Based on the argument input(client_ftx OR client_ptm),the script shall read the particular entries from the control file like ftp host,user,pwd and connect.
I have a solaris box where i use bash. The awk command is failing (error attached).This script works fine in Linux but fails when i run from solaris.
Any help is appreciated.

(1)Script
******
Code:
#!/bin/ksh

YESTERDAY=`TZ=GMT+29 date +%Y%m%d`
ftpClient=$1
ftpPropertyFile=/app/temp/ftpProperties.control
cat $ftpPropertyFile|sed -n "/$ftpClient/,/<<EOF/p"|awk -v 'RS=\n\n' '1;{exit}'|tail -n +2 > $ftpClient.txt
. ./$ftpClient.txt
echo "start of script"
ftp -nv $HOST <<END_SCRIPT
user $USER $PASSWORD
cd $SOURCEPATH
lcd /data/file
get $FILENAME1$YESTERDAY
bye
END_SCRIPT

echo "end of script"

(2)Control File
************
Code:
[client_ftx]
HOST=ftpprod.com
USER=sam
PASSWORD=abc123
SOURCEPATH=/samdir
FILENAME1="stor_cax."


[client_ptm]
HOST=ids.com 
USER=ftpuser
PASSWORD=xyz234
SOURCEPATH=/ftpdir
FILENAME1="previousday.srv"

(3)Error
*******
Code:
usage: tail [+/-[n][lbc][f]] [file]
       tail [+/-[n][l][r|f]] [file]
start of script
Not connected.
Not connected.
awk: syntax error near line 1
awk: bailing out near line 1
Local directory now /data/file
Not connected.
end of script


Last edited by samrat dutta; 04-07-2014 at 02:29 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking for a control file before processing a data file

Hi All, I am very new to Shell scripting... I got a requirement. I will have few text files(data files) in a particular directory. they will be with .txt extension. With same name, but with a different extension control files also will be there. For example, Sample_20081001.txt is the data... (4 Replies)
Discussion started by: purna.cherukuri
4 Replies

2. Programming

Cannot read a file with read(fd, buffer, buffersize) function

# include <stdio.h> # include <fcntl.h> # include <stdlib.h> # include <sys/stat.h> int main(int argc, char *argv) { int fRead, fPadded, padVal; int btRead; int BUFFSIZE = 512; char buff; if (argc != 4) { printf ("Please provide all of the... (3 Replies)
Discussion started by: naranja18she
3 Replies

3. Shell Programming and Scripting

Control file

if TERM has the value vt220, where will you expect to find its control file (0 Replies)
Discussion started by: thelakbe
0 Replies

4. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

5. Shell Programming and Scripting

while "read" UNIDATA control character

I have a UNIDATA file with this line EIR.ENTRYýIND.RATE.CALCýBUILD.EIR.ITEMýIND.RATES.WEBSERVICEýIND.GRP.COMPLIANCEýIND.RATE.AUDIT If I edit my unidata file with Notepad++ or something and replace ý with ~ then this works IFS="~" while read DATA do My question is what do I need... (14 Replies)
Discussion started by: hpodhrad
14 Replies

6. Shell Programming and Scripting

Formatting file data to another file (control character related)

I have to write a program to read data from files and then format into another file. However, I face a strange problem related to control character that I can't understand and solve. The source file is compose of many lines with such format: T_NAME|P_NAME|P_CODE|DOCUMENT_PATH|REG_DATE ... (3 Replies)
Discussion started by: hk6279
3 Replies

7. Shell Programming and Scripting

Check whether file is processed in a control file list

I've a list of files which got processed in Target table A and stored in a control file(list of control files). I've want to trigger another process (later) based on this list of files and load into Target table B and continue running this process until this file list is exhuasted. How do I come... (1 Reply)
Discussion started by: manojg9
1 Replies

8. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

9. UNIX for Beginners Questions & Answers

Creating script to read many files and load into database via single control file

Hi, I have many files but with only 2 names , I want to load the data of that file into database through sqlldr with single control file. how can i do that ????? Example: switch_file switch_file billing_file billing_file now these files should be loaded into same database but different... (1 Reply)
Discussion started by: niti_sharma
1 Replies
DH_INSTALLDEB(1)						     Debhelper							  DH_INSTALLDEB(1)

NAME
dh_installdeb - install files into the DEBIAN directory SYNOPSIS
dh_installdeb [debhelperoptions] DESCRIPTION
dh_installdeb is a debhelper program that is responsible for installing files into the DEBIAN directories in package build directories with the correct permissions. FILES
package.postinst package.preinst package.postrm package.prerm These maintainer scripts are installed into the DEBIAN directory. Inside the scripts, the token #DEBHELPER# is replaced with shell script snippets generated by other debhelper commands. package.triggers package.shlibs These control files are installed into the DEBIAN directory. package.conffiles This control file will be installed into the DEBIAN directory. In v3 compatibility mode and higher, all files in the etc/ directory in a package will automatically be flagged as conffiles by this program, so there is no need to list them manually here. package.maintscript Lines in this file correspond to dpkg-maintscript-helper(1) commands and parameters. Any shell metacharacters will be escaped, so arbitrary shell code cannot be inserted here. For example, a line such as "mv_conffile /etc/oldconffile /etc/newconffile" will insert maintainer script snippets into all maintainer scripts sufficient to move that conffile. A versioned Pre-Dependency on dpkg is needed to use dpkg-maintscript-helper(1). An appropriate Pre-Dependency is set in ${misc:Pre-Depends} ; you should make sure to put that token into an appropriate place in your debian/control file. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 9.20120909 2011-09-12 DH_INSTALLDEB(1)
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy