If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > pickup file from folder

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-07-06, 00:20
ram2s2001 ram2s2001 is offline
Registered User
 
Join Date: Oct 2005
Posts: 17
pickup file from folder

Hi,
Can any body help me,How to pickup file from folder using shellscript.

FolderName:/test
FileinFolder: test.txt

MY req ishellscript pickup file from folder and pass file as parameter to java program..?

Thanks,
Rams
Reply With Quote
  #2 (permalink)  
Old 03-07-06, 14:09
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


Try somethiing like:
Code:
#!/bin/ksh
file=/test/test.txt
java com.domain.MyApp****nJob $file

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 03-08-06, 01:17
ram2s2001 ram2s2001 is offline
Registered User
 
Join Date: Oct 2005
Posts: 17
file=/test/test.txt
java com.domain.MyApp****nJob $file


if i give this in java its taking file as /test/test.txt

i wanted to take only file as test.txt


Thanks lot
Rams
Reply With Quote
  #4 (permalink)  
Old 03-08-06, 04:27
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Code:
#!/usr/bin/ksh
file1=/test/test.txt
## 
FolderName1=$(dirname $file1)
FileinFolder1=$(basename $file1)
echo $FolderName1 $FileinFolder1
## OR
file2=/test/test2.txt
FolderName2=${file2%/*} 
FileinFolder2=${file2##*/} 
echo $FolderName2 $FileinFolder2
Reply With Quote
  #5 (permalink)  
Old 03-08-06, 06:11
ram2s2001 ram2s2001 is offline
Registered User
 
Join Date: Oct 2005
Posts: 17
Hi pdreyer,
Thanks lot ,here iam getting file name but not getting content in file,empty file name is giving...?

Thanks
Rams
Reply With Quote
  #6 (permalink)  
Old 03-08-06, 16:08
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


Like this?:
Code:
#!/bin/ksh
cd /test
file=test.txt
java com.domain.MyApp****nJob $file

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #7 (permalink)  
Old 03-09-06, 02:00
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Quote:
here iam getting file name but not getting content in file
Yes, my code just show you how to delete any prefix ending in / or to deliver all but the last level of the path name.
Replace the echo command with the java command and pass the file name as argument as in the sample from LKBrwn_DBA
Reply With Quote
  #8 (permalink)  
Old 03-09-06, 09:05
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


Better show us your code.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #9 (permalink)  
Old 03-27-06, 02:31
ram2s2001 ram2s2001 is offline
Registered User
 
Join Date: Oct 2005
Posts: 17
Thanks guys,

I need one more clarification...

My files dumped into folder FileName followed by Timestamp.That is the case how to pick up file from folder and pass to javaprogram...?

ThanksLot
Reply With Quote
  #10 (permalink)  
Old 03-27-06, 02:55
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
I do not understand your question. Do you want to find the latest file in the directory?.
Reply With Quote
  #11 (permalink)  
Old 03-27-06, 04:17
ram2s2001 ram2s2001 is offline
Registered User
 
Join Date: Oct 2005
Posts: 17
Hi pdrey,
that's correct ,I want to pickup latest file from Folder..

ThanksLot
Reply With Quote
  #12 (permalink)  
Old 03-27-06, 10:03
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
Quote:
Originally Posted by ram2s2001
that's correct ,I want to pickup latest file from Folder..
Like this?
Code:
#!/bin/ksh
cd /test
ls -1t | read file
java com.domain.MyApp****nJob $file
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On