The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Auto copy for files from folder to folder upon instant writing Bashar UNIX for Advanced & Expert Users 2 2 Weeks Ago 11:44 AM
Search for a File Name in a folder sbasetty Shell Programming and Scripting 1 07-13-2007 02:43 PM
file name in folder u263066 Shell Programming and Scripting 5 10-12-2006 05:37 AM
Take a folder name and find it in another folder (Complicated) hkhan12 Shell Programming and Scripting 5 09-06-2006 09:25 AM
getting a file name from a folder u263066 Shell Programming and Scripting 4 08-14-2006 08:10 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2007
Registered User
 

Join Date: Jul 2007
Posts: 7
Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and suffix are of a fixed size.

e.g:
1) 20070701greenfieldincfile.txt (Folder Name: greenfieldinc)
2) 20070701oldenergycorpfile.txt (Folder Name: oldenergycorp)

Detailed Request:
1) Parse the Input File name and Find the name of the folder.
2) FTP to Windows server and place the text file in the corresponding folder.
3) Put the whole process in loop until it processes all files.
4) If possible any error check conditions or logs.

Thank you for your support!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-02-2007
Registered User
 

Join Date: Jun 2007
Posts: 5
Try this

#!/usr/bin/ksh
ls -1 *file.txt | while read FILENAME
do
DIRNAME=`echo "$FILENAME" | sed -n 's/........\(.*\)file.txt/\1/p'`
echo "starting FTP of $FILENAME to Directory /tmp/$DIRNAME ..."
ftp -v -n host <<EOF
user user pwd
cd /tmp/$DIRNAME #destination Dir
lcd /tmp/source/ #source dir
put "$FILENAME"
bye
EOF
done
Reply With Quote
  #3 (permalink)  
Old 07-03-2007
Registered User
 

Join Date: Jul 2007
Posts: 7
Grant File privileges

The provided script did work. Thank You so much!

However, the created file hasn't been granted 'write' privileges to the user. The file is getting created through Oracle trigger and the process automatically uses 'dbadmin' user on UNIX.

Is there any way that we can force UNIX to provide 'r' & 'w' privileges to group and other members for the files that get generated through that process or files that get generated in the specified directory.

Any help is greatly appreciated.

Thanks!
Reply With Quote
  #4 (permalink)  
Old 07-03-2007
Shell_Life's Avatar
Unix/Informix/4GL/SQL
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
To set subsequently created files to a specific privileges:
Code:
man umask
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0