Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2005
    Posts
    17

    Unanswered: 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

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


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

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Oct 2005
    Posts
    17
    file=/test/test.txt
    java com.domain.MyApp.RunJob $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

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    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

  5. #5
    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

  6. #6
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


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

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  7. #7
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    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

  8. #8
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Better show us your code.

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  9. #9
    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

  10. #10
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    I do not understand your question. Do you want to find the latest file in the directory?.

  11. #11
    Join Date
    Oct 2005
    Posts
    17
    Hi pdrey,
    that's correct ,I want to pickup latest file from Folder..

    ThanksLot

  12. #12
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.RunJob $file

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •