Here is my shell below. I am trying to basically fetch .csv file using ftp to get .csv into a directory. Name of the file could be possibly like
missingtrades_20130530.csv or
missingtrades_20130531.csv
Can I pass these .csv files as parameters since the file name is varying, how do I run the shell passing the parameters. Please help, this is kind of urgent
#!/bin/ksh -xvedateHOME_DIR=$tradehome/ods#DOWNLOAD_FILE_NAME=test_0523.csvDOWNLOAD_FILE_NAME=$1.csvDATA_FILE_DIR=$HOME_DIR/data/csvDATA_FILE=$DATA_FILE_DIR/$DOWNLOAD_FILE_NAMEdscfname=$HOME_DIR/log/stg_citco_intraday_trade_sqlldr.dscbadfname=$HOME_DIR/log/stg_citco_intraday_trade_sqlldr.bad#ftplog = $HOME_DIR/log/ftp_get_msg_data.logremote=cnyopdsuatUSER_NAME=opduPASSWORD=snp500export USER_NAME PASSWORD remote ftplog DATA_FILE_NAMEuntil[ -f "$DATA_FILE" ]do sleep 2 date echo 'Attempt to get $DATA_FILE from $remote' `date` cd $DATA_FILE_DIR echo "open $remote user $USER_NAME $PASSWORD verbose asc cd pranathi get $DOWNLOAD_FILE_NAMEquit" | ftp -in > $ftplog 2>&1donedate
Name of my shell script - stg_citco_intraday_trade_v1.sh
File I wanted to pass on as parameter - Citco_missingtrades_20130523
Am trying to rename the Citco_missingtrades_20130523 as sample.csv
Now I have another issue, I included sqlloader as part of my shell and it is loading into the table STG_CITCO_INTRADAY_TRADE. The very first column of this table has the sequence number.
Whenever data gets loaded into this table STG_CITCO_INTRADAY_TRADE, sequence number column should be 2013052300001, 2013052300002 and so on..
If the file that is being as passed as parameter is Citco_missingtrades_20130530, then the
sequence number column should be 2013053000001, 2013053000002 and so on..
2) Edit the stg_citco_intraday_trade_ctl.tmp file as follows:
load datainfile '$tradehome/ods/data/csv/sample.csv'replace into table stg_citco_intraday_trade fields terminated by ',' optionally enclosed by '"'trailing nullcols ( STG_SEQUENCE_NUMBER SEQUENCE(%SEQNO%), ORD_STATUS "TRIM (:ORD_STATUS)", . . . E t c . . .
One last question, what if I wanted to execute as
stg_citco_intraday_trade_v1.sh 20130530, I mean to say if the parameter I wanted to pass is only the date and the file could be
. . . E t c . . .trailing nullcols ( STG_SEQUENCE_NUMBER EXPRESSION "%SEQNO% + stg_sequence.nextval", ORD_STATUS "TRIM (:ORD_STATUS)", . . . E t c . . .
I tried to make changes as suggested. Attached are the control, shell files but I get strange results. I also attached the .csv file which I used for execution.
Here is the sequence number I get for all the records
2.0130523E17
I did attach the result in the table and you can see the sequence number. I defined the datatype for stg_sequence number in the table initially as number, now I changed it to Number(38).. still, it gives me the same result.
Thank you for your reply. I am still struggling to get the right sequence number. As I said before, I am loading the table stg_citco_intraday_trade thru sqlloader. Can I set number to 23 digits in my control file. Attached is my control file.
or is there anyway that I can change my shell to set the number to 23.
. . . E t c . . .DOWNLOAD_FILE_NAME="Citco_missingtrades_$1.csv"LOAD_DATE="${1}". . . E t c . . .sed "s/%LOAD_DATE%/$LOAD_DATE/" $tradehome/ods/ctl/stg_citco_intraday_trade_ctl.tmp > $tradehome/ods/ctl/stg_citco_intraday_trade.ctl. . . E t c . . .
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Background
Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc...
As a "Unix" shop, our only readily …
Learn how to navigate the file tree with the shell.
Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3. In this video, we show how to load the export from S3 into a DynamoDB table.