Lscd - simple ranger implementation in POSIX shell

I've been casually working on a file browser that has a similar interface like ranger, but takes a different approach, in that it is written in bash POSIX shell.
I wanted to combine the elegance, portability and simplicity of a short bash shell script with the ability to get me whereever I want ASAP without the "cd TAB TAB TAB" boilerplate.  Additionally, it can use ranger's file opener "rifle" to execute files just the way ranger does.
I'm not finished yet, but there is a working alpha version at github:
https://github.com/hut/lscd
It uses the basic h/j/k/l vim type movement control keys. Check the source for more key bindings, it makes no sense to write a complete list at this stage of development.
And the obligatory screen shot:
As you can see, there are no miller columns like in ranger. That may or may not change in the future. I suspect it would be too slow in shell script.
Pro tip: if you run lscd with the command ". lscd", it will run in the current bash environment, rather than in a new one. Only this way the directory will actually change after you close lscd.
Last edited by hut (2014-09-11 12:13:45)

Really cool.
falconindy wrote:Aliasing ls will break (e.g. alias ls='ls --color') this. You shouldn't be using ls at all, but rather glob expansion....
In case you source it it will use the alias/function, so indeed, be careful with that.
Here's a template I always use for adding cursor movement:
(starting with line 147)
(adjust to posix shell yourself)
(the -t 0.01 newinput is "beatable" like if you hold the cursor newinput will get larger. That's why there's a "$newinput" =~ [~A-Da-d] for cursor keys and shift+cursor keys)
read -n 1 -s input
if [[ "$input" == $'\e' ]]; then
input=ESC
while true; do
read -n 1 -s -t 0.01 newinput < /dev/tty
[[ "$newinput" == $'\e' ]] && newinput=ESC
input=${input}${newinput}
[[ -z "$newinput" || "$newinput" =~ [~A-Da-d] ]] && break
done
fi
case "$input" in
'ESC[A') "code for up, etc"
;; #Up
'ESC[B')
;; #Down
'ESC[6~')
;; #Page Down
'ESC[5~')
;; #Page Up
'ESC[4~'|'ESC[F'|'ESC[8~'|'ESCOF')
;; #End
'ESC[1~'|'ESC[H'|'ESC[7~'|'ESCOH')
;; #Home
'ESC[D')
;; #Left
'ESC[C')
;; #Right
'ESC[3~')
;; #Delete

Similar Messages

  • Byte-ranging implementation (correct version)

    I am trying to implement byte-ranging support for WebLogic 6.0.
              Unfortunately, Acrobat Reader does not understand my http response with
              ranges and crashes (or waits for something forever). Does anybody have any
              idea what might be wrong? See my code below.
              Is there a java servlet already that implements byte-ranging?
              Thank you,
              Andrei
              import java.io.*;
              import java.util.*;
              import javax.servlet.*;
              import javax.servlet.http.*;
              /** For testing only, do not look at it. */
              public class ViewFile extends HttpServlet
              public void service(HttpServletRequest req, HttpServletResponse res) throws
              ServletException, IOException
              System.out.println("ViewFile start at " + new Date());
              // Print the headers
              for (Enumeration e = req.getHeaderNames() ; e.hasMoreElements() ;)
              String name = (String)e.nextElement();
              System.out.println("> " + name + ": " + req.getHeader(name));
              // Get the file to view
              String file = req.getPathTranslated();
              // No file, nothing to view
              if (file == null)
              file = getServletContext().getRealPath("/index.html");
              System.out.println(file);
              // OK. Do the job!
              renderFileWithByteRanging(file, req, res);
              System.out.println("ViewFile finish\n");
              /** Represents a single byte range. */
              class Range
              public Range(long start, long end)
              this.start = start;
              this.end = end;
              /** The start of the range (zero based). */
              public long start;
              /** The end of the range. */
              public long end;
              * Parses the incoming ranges into a list of ranges.
              * @param ranges The string containing the ranges.
              * @param fileLength The length of the file.
              public LinkedList parseRanges(String ranges, long fileLength) throws
              Exception
              // Create an empty range list
              LinkedList result = new LinkedList();
              // Remove the "bytes=" part from the range
              int pos = ranges.indexOf('=');
              if (pos == -1)
              throw new Exception("Malformated range request: no '=' symbol");
              if ("bytes".equalsIgnoreCase(ranges.substring(pos).trim()))
              throw new Exception("Malformated range request: 'bytes'
              expected");
              ranges = ranges.substring(pos + 1);
              // Go through the range string and extract the ranges
              StringTokenizer tok = new StringTokenizer(ranges, ",");
              while (tok.hasMoreTokens())
              // Get the next range
              String rangesPart = tok.nextToken().trim();
              // Find a minus separating the range
              pos = rangesPart.indexOf('-');
              if (pos == -1)
              System.out.println("Malformated range request: no '-' symbol");
              continue;
              String strFirst = rangesPart.substring(0, pos).trim();
              String strLast = rangesPart.substring(pos + 1).trim();
              System.out.println("Parsed range: " + strFirst + "-" + strLast);
              long posFirst;
              long posLast;
              if ("".equals(strFirst)) // The first parameter is missing
              // Last n bytes. Example: -500
              posFirst = fileLength - Integer.parseInt(strLast);
              posLast = fileLength;
              else if ("".equals(strFirst)) // The second parameter is missing
              // All bytes except first n bytes. Example: 500-
              posFirst = Integer.parseInt(strFirst);
              posLast = fileLength;
              else // Full range request
              // All bytes from n to m. Example: 500-600
              posFirst = Integer.parseInt(strFirst);
              posLast = Integer.parseInt(strLast);
              // Final checks
              if (posLast > fileLength)
              posLast = fileLength - 1;
              if (posFirst >= posLast)
              posFirst = 0;
              posLast = fileLength - 1;
              // Add the range to the list
              result.addLast(new Range(posFirst, posLast));
              // That's all
              return result;
              /** Put entire file to the outpt stream. */
              public void renderFile(ServletOutputStream sos, File file) throws
              Exception
              FileInputStream fis = null;
              try
              // Create the input stream
              fis = new FileInputStream(file);
              // Allocate the 4K buffer
              byte[] buffer = new byte[4 * 1024];
              // Copy the input to the output
              int bytesRead;
              while((bytesRead = fis.read(buffer)) != -1)
              sos.write(buffer, 0, bytesRead);
              finally
              if (fis != null)
              fis.close();
              /** Put the range of the file to the output stream. */
              public void renderFileRange(ServletOutputStream sos, File file, Range
              range) throws Exception
              FileInputStream fis = null;
              try
              System.out.print("Serving range: " + range.start + "-" + range.end);
              // Create the input stream
              fis = new FileInputStream(file);
              // Skip the first bytes
              if (range.start > 0)
              long skipped = fis.skip(range.start);
              System.out.print("; skipped=" + skipped);
              // Read the requested bytes
              int rangeLength = (int)(range.end - range.start + 1);
              byte[] buffer = new byte[rangeLength];
              int bytesRead = fis.read(buffer, 0, rangeLength);
              // Write the bytes
              if (bytesRead > 0)
              sos.write(buffer, 0, bytesRead);
              System.out.println("; read=" + bytesRead);
              finally
              if (fis != null)
              fis.close();
              /* Calculate multi part content length. May not work properly. */
              public long calculateContentLength(LinkedList ranges, long fileLength,
              String contentType)
              String str;
              long length = -2;
              String boundary = "multipart-boundary";
              for (Iterator i = ranges.iterator(); i.hasNext();)
              // Get the next range
              Range range = (Range)i.next();
              // Render a new boundary
              str = "--" + boundary +
              "Content-type: " + contentType +
              "Content-range: bytes " + range.start + "-" +
              range.end + "/" + fileLength;
              length += 10 + str.length() + range.end - range.start + 1;
              str = "--" + boundary + "--";
              length += 4 + str.length();
              System.out.println("Multi-range response length: " + length);
              return length;
              * Render the specified file to the output stream.
              * The whole file is rendered in binary mode, no other output is
              allowed.
              * @param fileName The name of the file render.
              public void renderFileWithByteRanging(String fileName,
              HttpServletRequest request, HttpServletResponse response) throws IOException
              System.out.println("Serving the file: " + fileName);
              FileInputStream fis = null;
              try
              // Get the output stream
              ServletOutputStream sos = response.getOutputStream();
              // Get and set the type of the file
              String contentType = getServletContext().getMimeType(fileName);
              System.out.println("Content Type: " + contentType);
              // Open file and its length
              File file = new File(fileName);
              long fileLength = file.length();
              System.out.println("File length: " + fileLength);
              // Get ranges
              String httpRange = request.getHeader("Range");
              // Are ranges requested?
              if (httpRange == null)
              // No ranges needed
              System.out.println("No ranges. Proceed in usual way");
              response.setHeader("Accept-ranges", "bytes");
              response.setContentType(contentType);
              response.setHeader("Content-length",
              String.valueOf(file.length()));
              // Disable all kinds of caching
              // response.setHeader("Cache-Control", "no-store");
              // Render the entire file content
              renderFile(sos, file);
              else
              // Well, ranges.......
              System.out.println("Ranges are requested.");
              LinkedList ranges = parseRanges(httpRange, fileLength);
              Range range;
              // Check if we got a single range request
              if (ranges.size() == 1)
              // Yeah... a single range. Return it in the simple form
              (Apache-style)
              System.out.println("Serving a single range.");
              range = (Range)ranges.getFirst();
              sos.println("Status: 206 Partial content");
              sos.println("Content-range: bytes " + range.start + "-"
              + range.end + "/" + fileLength);
              sos.println("Content-length: " + (range.start -
              range.end + 1));
              sos.println("Content-type: " + contentType);
              sos.println();
              sos.println();
              // Render the range of the file
              renderFileRange(sos, file, range);
              else
              // Well... many ranges. Return a multipart response
              System.out.println("Serving multiple ranges.");
              // Render the multi-parse response header
              String boundary = "multipart-boundary";
              sos.println("Status: 206 Partial content");
              sos.println("Accept-ranges: bytes");
              sos.println("Content-type: multipart/x-byteranges; boundary=" +
              boundary);
              // sos.println("Content-length: " + calculateContentLength(ranges,
              fileLength, contentType));
              sos.println();
              // Go through the range list and return the
              corresponding file bits
              for (Iterator i = ranges.iterator(); i.hasNext();)
              // Get the next range
              range = (Range)i.next();
              // Render a new boundary
              sos.println();
              sos.println("--" + boundary);
              sos.println("Content-type: " + contentType);
              sos.println("Content-range: bytes " + range.start +
              "-" + range.end + "/" + fileLength);
              sos.println();
              // Render the range of the file
              renderFileRange(sos, file, range);
              // Finish the multipart response
              sos.println();
              sos.println("--" + boundary + "--");
              System.out.println("Done Serving");
              catch(FileNotFoundException fnf)
              // Send the file-not-found status if we could not open the file
              response.sendError(response.SC_NOT_FOUND);
              System.out.println("File '" + fileName + "' is not found");
              catch(Exception e)
              // Send the internal-error status for all other reasons
              if (!response.isCommitted())
              response.sendError(response.SC_INTERNAL_SERVER_ERROR,
              e.getMessage());
              e.printStackTrace();
              

    First just to clarify EBS is currently using OAF and not ADF.
    More info here:
    http://blogs.oracle.com/schan/2007/06/28#a1721
    OAF uses ADF Business Components - so if you want to use ADF to build a system that will integrate with EBS then it would make sense to go to the "ADF Tutorial for Forms/4GL Developers" tutorial.

  • Implementation of Posix Thread class in c++ for solaris system

    Hello Everyone,
    Please help me with information regarding how to implement Posix Thread Class in c++ for Solaris 5.8 system.
    if available Please let me know any Open Source Posix Threads C++ built-in library available for Solaris System.
    Thanks in Advance.
    Thanks & Regards,
    Vasu

    Posix threads are available on Solaris, and can be used directly in C or C++ programs. Include the header <pthread.h> to get access to the types, constants, and functions. Compile with the option
    -mt
    on every command line, and link with the options
    -mt -lpthread
    If you want to create a class to provide a different sort of interface to phreads you can do so by building on the <pthread.h> functionality.

  • Simple Microblaze implementation using vivado

    hello
    i get recently my new basys3 board, and i try to implement a simple project based on a microblaze and an gpio ip core to generate a simple signal and get this signal on a pmod pin connector using vivado, and as this is the first time I used Vivado i find a little bit difficult to run the implementation. i attached the different files with this message include the c programe. i can generate a bitstream file and build a project in SDK also i can implement the design in the basys3 board, but when i check the signal in the pmode connector it seem like nothing happen.
    i appreciate any help or suggestion in order to remedy this problem.
    Best regards

    Hello,
    I have tested this.
    I couldn't add the router-traffic to the ip inspect rule for ssh but could add it to the ip inspect rule with tcp.
    I tested this option but unfortunatly the connection was closed again as soon the rules were applied to the interfaces.
    Maybe I did it wrong or it doesn't work.
    //Edwin

  • Simple Pekwm Categorized Menu Populator (Shell Script)

    I wanted to share this script I wrote in the hope that it will prove to be as convenient to some of you as it has been to me.
    Suggestions and modifications are welcome.
    #! /bin/sh
    #USING WITH PEKWM
    # -Install this file to ~/.pekwm/scripts/menugen.sh
    # -Add this line to ~/.pekwm/start:
    # ~/.pekwm/scripts/menugen.sh > ~/.pekwm/dynamic
    # -Add this line where desired to the RootMenu section of ~/.pekwm/menu:
    # INCLUDE = "dynamic"
    # -Reload Pekwm
    # -Restart Pekwm
    #This will allow the menu to regenerate each time Pekwm restarts.
    #MAKING ADJUSTMENTS
    #Select a list of categories into which you would like your applications to be sorted, then add them to the "CATS=..." line below separated by spaces.
    #Some common values are:
    # CATEGORY DESCRIPTION
    # AudioVideo Application for presenting, creating, or processing multimedia (audio/video)
    # Audio An audio application Desktop entry must include AudioVideo as well
    # Video A video application Desktop entry must include AudioVideo as well
    # Development An application for development
    # Education Educational software
    # Game A game
    # Graphics Application for viewing, creating, or processing graphics
    # Network Network application such as a web browser
    # Office An office type application
    # Science Scientific software
    # Settings Settings applications Entries may appear in a separate menu or as part of a "Control Center"
    # System System application, "System Tools" such as say a log viewer or network monitor
    # Utility Small utility application, "Accessories"
    #For a better idea of how your applications may be categorized, you may also want to inspect the contents of the "Categories=" line of the various *.desktop files under /usr/share/desktop/
    CATS="Audio Graphics Network Settings System Utility"
    for CAT in $CATS; do
    echo " Submenu = \"$CAT\" {"
    for CATMATCH in `grep -l "^Categories=.*$CAT.*" /usr/share/applications/*.desktop`; do
    name=`sed -n '1,/^Name=/ s/^Name=//p' <$CATMATCH`
    exec=`sed -n '1,/^Exec=/ s/^Exec=//p' <$CATMATCH`
    echo " Entry = \"$name\" { Actions = \"Exec ${exec% %[UuFf]}\" }"
    done
    echo " }"
    done

    No matter how you chose to do it it's going to be a bit more work than a simple shell script. There are a lot of choices though.
    Objective-C/Cocoa (this is how most of the big boys do it)
    http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/01Introdu ction/chapter1_section1.html
    AppleScript Studio
    http://developer.apple.com/documentation/applescript/conceptual/studiobuildingap ps/chapter01/chapter1_section1.html
    Python/Cocoa bridge
    http://developer.apple.com/cocoa/pyobjc.html
    There are more options if none of these appeal to you.
    Eric

  • A simple BADI implementation - very urgent

    Hi,
      I am new to ABAP. I need a small piece of coding. I am implementing a BADI. There is a table which has 3 fields (MATID, LOCID, STATUS and PLANNING_DATE). For each MATID (material ID), there are many LOCID (Location ID) available. My BADI has to choose the suitable LOCID for the given MATID based on the following conditions :
    The LOCID for that particular MATID, must satisfy STATUS = salesprice and PLANNING_DATE = current date.
    <u>Code Logic :</u>
    <b>Input :</b> BADI gets a series of MATID and corresponding LOCID as input.
    <b>Logic :</b> For the MATID, choose one LOCID. Check whether the corresponding fields have STATUS = salesprice  and PLANNING_DATE = current date

    Hi Preetha,
    Assume that the BADI's interface has an internal table which has the table for matid, locid, status and planning_date say itab(In the badi method, check the correct name for the table).
    read table itab into wa with key matid = <Current Matid>
                                                  status = <sales priice>
                                                  planning_date = sy-datum.
    if sy-subrc = 0.
    You will have the chosen record.
    endif.
    Regards,
    Ravi

  • Simple idm implementation question

    Hi,
    Would anyone with IDM experience comment on what would it take to implement the following in IDM (assuming there are technical people available, though with no idm experience)
    1. There is no provisioning to the end systems
    2. A requestor logs in, creates a request -> approver logs in and approves -> implementer logs in and marks implemented (that last piece i imagine you'd need a custom workflow and form on a resource/role to add implementers) -> resource/role marked provisioned
    3. Basic audit reports for audit
    4. requester/approver/implemeter can be setup in different departments so they only see resources/roles for that department
    Your advice is much appreciated!

    I am no expert in IDM, but what you require is possible and explained in good detail as part of the Deployment Fundementals course run by Sun, which I attended about a month back. It would take too long to explain how to put it in place on this forum I'm afraid. You would need to attend the course. I don't have enough expereince to advise how long this would take. Hope this is of some help.

  • Simple firewall implementation

    Hello,
    I'm pretty new to the cisco product and want to setup a simple firewall.
    I found some exampels but can't get it to work.
    For now we are using Cisco routers 88x and 89x series.
    When I activate te script I the remote connection to the router is lost, although I have put an permit rule for ssh.
    The script is the following:
    ip inspect name Firewall tcp
    ip inspect name Firewall udp
    ip inspect name Firewall rtsp
    ip inspect name Firewall h323
    ip inspect name Firewall netshow
    ip inspect name Firewall ftp
    ip inspect name Firewall ssh
    ip access-list extended Allow-IN
     permit eigrp any any
     permit icmp any 192.168.2.0 0.0.0.255 echo-reply
     permit icmp any 192.168.2.0 0.0.0.255 unreachable
     permit icmp any 192.168.2.0 0.0.0.255 administratively-prohibited
     permit icmp any 192.168.2.0 0.0.0.255 packet-too-big
     permit icmp any 192.168.2.0 0.0.0.255 echo
     permit icmp any 192.168.2.0 0.0.0.255 time-exceeded
     permit tcp any 192.168.2.0 0.0.0.255 eq 22
     deny ip any any
    interface Vlan1
     ip inspect Firewall in
    interface Dialer1
     ip access-group Allow-IN in
    Can anyone tell me what I'm doing wrong here?
    And a second question, can I use for the ip inspect also port numbers or must I always use a service name?
    Thank you,
    //Edwin

    Hello,
    I have tested this.
    I couldn't add the router-traffic to the ip inspect rule for ssh but could add it to the ip inspect rule with tcp.
    I tested this option but unfortunatly the connection was closed again as soon the rules were applied to the interfaces.
    Maybe I did it wrong or it doesn't work.
    //Edwin

  • Simple ResourceAdapter implementation

    I am trying to deploy a ResourceAdapter which only uses BootstrapContext.ctx.createTimer() and getWorkManager() to execute tasks within the webapplication, it has no communication with other systems.
    On a resin-server this gets started by adding
    <resource jndi-name="jca/taskEngine" type="myclasses.TaskEngine"/>
    For deploying this on oc4j i have tried packaging this ra.xml:
    <?xml version="1.0" ?>
    <connector xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
    version="1.5">
    <description>experimental jca 1.5 resource adapter</description>
    <display-name>taskengine</display-name>
    <vendor-name>tester</vendor-name>
    <eis-type>test</eis-type>
    <resourceadapter-version>0.0</resourceadapter-version>
    <resourceadapter>
    <resourceadapter-class>myclasses.taskengine</resourceadapter-class>
    </resourceadapter>
    </connector>
    and a jar with the class into taskengine.rar.
    Then running this command:
    E:\oracle2\ora92\dcm\bin>dcmctl deployApplication -f e:\test3\taskengine.rar -a taskengine
    This extracts the files to ...j2ee/home/connectors
    and adds this entry
    <connector name="taskengine" path="taskengine.rar">
         </connector>
    to oc4j-connectors.xml.
    The start(BootstrapContext bootstrapContext) - method is still not executed.
    Dont' know if I am even on the right track here, any tips would be greatly appreciated.
    best regards, lars

    Hi Ripal,
    Following are the steps which would be used to achieve the objective:
    We have to define following dictionary types for creating the relation:
    Data dictionary related developments
         a. Z Table with all fields needed to be captured
         b.A structure having all the fields of Z table
         c. A table type same as the Z table
         d. Structure having only key fields of Z table
      2. SPRO settings :
         To create this relation go to SPRO :
    Customer Relationship Management->CRM Cross-Application Components ->Generic Interaction Layer/Object Layer->Business Transactions
    Here we need to do all three tasks :
         a)  Extend Model for Business Transactions with New Nodes.
                   Click on New entries.
         b)  Extend Model for Business Transactions with New Relations.
    In this step we name the new relation. Click on new entries and maintain new entries as shown.
    The  Source object is the parent relation(External Object name) on which our relation is dependent.
    As we have to store n records for 1 opportunity header hence relation is (1: 0…n ).
         c) Define Custom Handler Classes for Business Transaction Model Nodes.
                        In This step we have to mention the name of Class which is inherited from the Genil class      of      parent relation.      
    Methods :
    We haveto implement two methods here :
      IF_CRM_RUNTIME_BTIL~READ_ATTRIBUTES
      IF_CRM_RUNTIME_BTIL~MAINTAIN_ATTRIBUTES
    Once all these steps are completed the new relation is created and can be accessed as dependent object in bol.
    Regards,
    Chiru

  • Simple shell script issue

    Hi,
    I have an issue with following shell script:
    #!/bin/sh
    env | while read VAR; do
    RIGA=$RIGA"\""$VAR"\";"
    done
    echo $VAR
    echo $RIGA
    exit 0
    Why the last echo commands (echo $VAR and echo $RIGA) don't give me any result? Why $VAR and $RIGA are empty?

    From what I understand, anything to the right of a pipe is run in a sub-process in non POSIX shells, which runs in it's own environment. Variables changed inside ta sub-shell are not changed at the parent process.
    Perhaps using ksh instead of bourne shell will work, or you could try input redirection rather than using pipe command. e.g.:
    while read VAR; do
    RIGA=$RIGA"\""$VAR"\";"
    done < $(env)
    echo $VAR
    echo $RIGA
    exit 0
    Edited by: Dude on Dec 15, 2010 6:11 AM

  • Implementing UI shell

    Hi,
    I am using JDeveloper 11g.
    I need to create a UI page template that includes some known components as menues and some dynamic components that will be filled at runtime.
    In Developer Guide I found a section that deals with these issues: "implementing UI shell and navigator menu UI features".
    The problem is that I tried to follow the instructions in the guide and implement them in JDEV 11g but it seems that a lot of things are missing; such as libraries (Aplications core and Applications Core Tag), UI Shell template option (when creating a new JSF page) etc'.
    My question is how can I implement the UI shell in JDEv 11g.
    Thanks,
    Orly

    Orly,
    It seems you may be an Oracle employee and referring to some internal documents - if so, you should use the internal Oracle forums for this question.
    If not, please share the document name and page reference where you are seeing this - I don't see anything resembling this in either the Fusion Developer's Guide or the Web UI Developer's Guide.
    John

  • How can I perform this kind of range join query using DPL?

    How can I perform this kind of range join query using DPL?
    SELECT * from t where 1<=t.a<=2 and 3<=t.b<=5
    In this pdf : http://www.oracle.com/technology/products/berkeley-db/pdf/performing%20queries%20in%20oracle%20berkeley%20db%20java%20edition.pdf,
    It shows how to perform "Two equality-conditions query on a single primary database" just like SELECT * FROM tab WHERE col1 = A AND col2 = B using entity join class, but it does not give a solution about the range join query.

    I'm sorry, I think I've misled you. I suggested that you perform two queries and then take the intersection of the results. You could do this, but the solution to your query is much simpler. I'll correct my previous message.
    Your query is very simple to implement. You should perform the first part of query to get a cursor on the index for 'a' for the "1<=t.a<=2" part. Then simply iterate over that cursor, and process the entities where the "3<=t.b<=5" expression is true. You don't need a second index (on 'b') or another cursor.
    This is called "filtering" because you're iterating through entities that you obtain from one index, and selecting some entities for processing and discarding others. The white paper you mentioned has an example of filtering in combination with the use of an index.
    An alternative is to reverse the procedure above: use the index for 'b' to get a cursor for the "3<=t.b<=5" part of the query, then iterate and filter the results based on the "1<=t.a<=2" expression.
    If you're concerned about efficiency, you can choose the index (i.e., choose which of these two alternatives to implement) based on which part of the query you believe will return the smallest number of results. The less entities read, the faster the query.
    Contrary to what I said earlier, taking the intersection of two queries that are ANDed doesn't make sense -- filtering is the better solution. However, taking the union of two queries does make sense, when the queries are ORed. Sorry for the confusion.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Calling shell script from sql procedure

    Hi gurus
    Is it possible
    1)to call a shell script from sql procedure
    2)that shell script has to return one value
    3)and again sql procedure(calling shell script) has to capture the return value.
    please help me to write this script

    You may NOT have EXECUTE privilege/ permissions on the DBMS_PIPE package. Check with your DBA.
    Using DBMS_PIPE may not be that simple to implement. Just making a call to DBMS_PIPE procedure will not do anything. It will NOT trigger anything on the UNIX side.
    . You will also need to :
    1.     Write a job (ie CRON) at UNIX side which will keep read the incoming pipe for new messages, Unpack the message and get the command to be executed at the UNIX side -- There will be a lot of work involved here + DBA presence/activity is also required.
    As Justin has pointed out, try and use HOST command which is very simple or try and use Java.
    Shailender Mehta

  • Shell script blog -OR- Give me tips on how to write better scripts!

    Hi folks,
    I don't write a lot of shell scripts, and the ones that I do write are usually quite short, so as a learning exercise I made a shell/CGI blog script.. And I was hoping that some of the shell scripting experts in the community could give me some pointers on form, style, etc! The script works just fine, but maybe I haven't coded it very elegantly. Or maybe in some places I haven't necessarily used the right (or most appropriate?) commands to accomplish what I want.
    It's a simple blog. It can either:
    - Display a blog post (by default the newest, unless the name of a post is given)
    - Display a listing of posts for a certain tag
    Posts are saved in normal files in markdown format. Tagging is accomplished by putting the name of the tag(s) into the filename, separated by hyphens. For example: the file "wonderful_blog_post-whining-computers-archlinux.md" would be a post named "wonderful blog post", and it would have three tags ("whining", "computers", "archlinux"). Maybe it's not the best idea in the world... but I went with it anyhow
    I put the script on pastebin for you all to see: http://pastebin.com/L8nMpUjT
    Please do take a look and let me know if I've done something badly! Hopefully I can learn a thing or two from your comments.
    And there's a working example of it here: http://www.ynnhoj.net/thedump/s.cgi

    falconindy wrote:
    To sort files by modification time (safely) requires GNU stat and some bash:
    declare -a files
    while IFS=$'\t' read -r -d '' ts file; do
    files+=("$file")
    done < <(stat --printf '%Y\t%n\0' * | sort -zn)
    printf "%s\n" "${files[@]}"
    The array is of course unnecessary as you could print inside the loop, but I see no way around the usage of null delimiters and bashisms (read's -d flag in particular) to be 100% safe.
    Thanks for the example, though I'm trying to avoid bash and write my script in posix shell. So after some tinkering, this is what I've come up with to make a simple list of blog post file names:
    #!/bin/sh
    cd posts
    while IFS=$'\t' read -r ts file; do
    ALLPOSTS="$ALLPOSTS $file"
    done << EOF
    $(stat --printf '%Y\t%n\n' *.md | sort -rn)
    EOF
    echo $ALLPOSTS
    So I suppose that it isn't 100% safe - but could it be acceptable? Is there anything else I could do?
    Edit: as it turns out, my server is running some flavour of BSD, I think FreeBSD. So the above examples don't work with FreeBSD's stat. Ah well..
    Last edited by upsidaisium (2011-02-23 08:26:29)

  • Simple RSA decryption error

    Hi All
    I am trying a very simple RSA implementations. I am not able to decrypt the data correctly. Please find my code below,
    import java.math.BigInteger;
    import java.util.Random;
    public class SimpleRSA {
         public static BigInteger p, q, N, v, k, d;
         public static void main(String[] args) {
              // p & q are prime numbers
              Random myRandom = new Random(0);
              p = BigInteger.probablePrime(32, myRandom);
              q = BigInteger.probablePrime(32, myRandom);
              System.out.println("Value of p:" + p);
              System.out.println("Value of q:" + q);
              // N = pq
              N = p.multiply(q);
              System.out.println("Value of N:" + N);
              // v = (p-1)*(q-1)
              v =
                   (p.subtract(BigInteger.valueOf(1))).multiply(
                        q.subtract(BigInteger.valueOf(1)));
              System.out.println("Value of v:" + v);
              // Compute k such that gcd(k, v) = 1
              k = new BigInteger("3");
              while(v.gcd(k).intValue() > 1) k = k.add(new BigInteger("2"));
              System.out.println("Value of k:" + k);
              // Compute d such that (d * k)%v = 1
              d = k.modInverse(v);
              System.out.println("Value of d:" + d);
              System.out.println("Public Key (k,N): (" + k + "," + N + ")");
              System.out.println("Private Key (d,N): (" + d + "," + N + ")");
              // Encryption
              String text = "Welcome to Java";
              System.out.println("Sample text:" + text);
              byte[] cipherData = text.getBytes();
              BigInteger a = new BigInteger(cipherData);
              System.out.println("BigInteger a:" + a);          
              BigInteger b = a.modPow(k, N);
              System.out.println("Encrypted data:" + b);
              // Decryption
              BigInteger c = b.modPow(d, N);
              byte[] decryptedData = c.toByteArray();          
              String plainText = new String(decryptedData);
              System.out.println("Decrypted data:" + plainText);     
    The answer I am getting is like this
    Value of p:3139482721
    Value of q:3180579707
    Value of N:9985375032889742747
    Value of v:9985375026569680320
    Value of k:7
    Value of d:4279446439958434423
    Public Key (k,N): (7,9985375032889742747)
    Private Key (d,N): (4279446439958434423,9985375032889742747)
    Sample text:Welcome to Java
    BigInteger a:1446156601937412646258
    Encrypted data:9678387382297663676
    Decrypted data:r��`�>B[/i]
    Please help me in this regard.
    Regards
    Kathirvel

    "m" (the integer rep of the message) must be strictly less than "N" (p*q). Look at the output - your p and q are too small for your data. Tryp = BigInteger.probablePrime(512, myRandom);
    q = BigInteger.probablePrime(512, myRandom);and try again.
    Then, go back and re-read the description of the RSA algorithm:
    http://en.wikipedia.org/wiki/RSA
    ("Applied Cryptography" would be bettr - but Wikipedia is at least a good start...)
    Grant

Maybe you are looking for

  • How do I select rows from the same table that have multiple occurances

    Hi Everybody, I am trying to select records from a detail table by grouping it. The table has more than 1 million records and the query is not performing well. The basic question is how to select a distinct record from a table which matches all value

  • Unable to see the generic datasource in BI system

    Hi All, I have created the Generic datasource in R3 using Function Module. i could see the Datasource in RSA6 .When i have replicated i could not find the datasource in the BI system .The source system is connected perfectly.could you please let me k

  • Facing problem in query template editor

    Hi All, After creating connection to MySQLserver in my machine through DATA Servers after that i tried to access that server(through name of server ex:mysqlconnect) in query template editor by following the procedure then i am not getting the modes l

  • Mac won't play Humax DVDs

    We have two emacs, an upgraded G4 and a Humax/Tivo DVDR. When we burn a DVD on the Humax, it plays in every other DVD player in the house, but will only play for five minutes in the Macs before it freezes the machine. Force quit is the only remedy. W

  • Public webservice as datasource, oracle database as destination

    Hello, So: there is some public webservice I need integrate with: http://www.granica.gov.pl/Services/czasyService/granica.wsdl. I need to set this webservice as data source with my odi project. What is the simplest way to do this? Is this possible to