LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-07-2009, 04:27 PM   #1
windjashi
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Need help writing Unix Shell script to pass file name,path,creation date !


Hi there
I'm new to UNIX scripting; Iím stuck with the following
I have an Oracle SQL script that takes three parameters
1- File Name
2- File Path
3- File creation date

Under UNIX I have a folder where files will be placed frequently and I need to upload those files to Oracle, what I need is a UNIX script that can do the following
Loop through Directory "/home/applmgr/snktmp"
Picks only files
Pass the file name to parameter &1
Pass the file path to parameter &2
Pass the file creation date to parameter &3

Call Oracle Script passing parameters &1,&2,&3
End loop

Is the above possible? I already knows how to call the Oracle Script from UNIX
Iím only stuck on writing the UNIX part where it List the files attribute(name,path,date) and store them to parameters ,Looping until the last file in the directory

If the above is not possible,then how can I create the below from the command line
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate

Thanks
 
Old 10-07-2009, 05:40 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Would
Code:
find -type f -printf "$ORACLE_CMD %h %f %c\n"
do? Not sure which timestamp you really need or in what format, but there are find flags for that.
 
Old 10-07-2009, 06:00 PM   #3
windjashi
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
hi

can you explain the line ? what does it do ! i have subtituted the $ORACLE_CMD with directory , but i'm not getting the following error
Usage: find [-H | -L] path-list [predicate-list]

Thanks
 
Old 10-07-2009, 06:20 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Yeah - that should have been
Code:
find PATH_TO_FILES -type f -printf "ORACLE_CMD %h %f %c\n"
where you replace PATH_TO_FILES with the path you want and ORACLE_CMD with the command you mean to be giving. Find searches the directory looking for regular files (-type f) and prints a formatted line (-printf) composed of ORACLE_CMD, the path, the filename, and the changetime, followed by a newline.

However, this is actually dumb - it does isolate the data you want (I think) and can generate a secondary script you can use (redirect the output of the command to a file, chmod file, execute file) but doesn't do anything itself. If that isn't sufficient (and it probably isn't) I'll see about something more sensible.

-- And maybe you can explain something to me - what does this mean?

Quote:
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Does this mean your command wants the three data bits in the form of 'foo:bar:baz' or something? Because it matters if the command is expecting space separated args or not.

Last edited by slakmagik; 10-07-2009 at 06:22 PM.
 
Old 10-08-2009, 12:59 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
@OP; just FYI, there's no such thing as creation date in *nix.
You've got ctime, mtime, atime see eg http://linux.die.net/man/1/find, none of which are creation time...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 05:48 PM
Shell script help: How to pass a directory path to the script? dv502 Programming 13 09-10-2008 03:07 AM
shell script to find modified date and last accessed date of any file. parasdua Linux - Newbie 6 04-22-2008 09:59 AM
Writing a shell script for copying file from one server to other by using third serve irfanb146 Linux - Newbie 4 03-07-2008 10:05 AM
Shell Script for Unix Date ??? ajeetraina Linux - Newbie 11 02-08-2008 12:58 AM


All times are GMT -5. The time now is 09:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration