Command line stuff

For some reason I can't get my program to run with the command line. It says that it can't find the main method, but when I run it in JCreator it works perfectly.
I set the path to "C:\Program Files\Java\jdk1.5.0_05\bin"
Then I went to the directory of the .class file.
Then I typed java Pong
What am I missing?

Path is irrelevant for finding classes. That only matters for finding java.exe.
Classpath is for finding classes. (Your IDE probably has its own settings, rather than the classpath envrionment variable or -cp command line options.)
Javapedia: Classpath
How Classes are Found
Setting the class path (Windows)
Setting the class path (Solaris/Linux)
Understanding the Java ClassLoader
java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

Similar Messages

  • I can't find a class to run command line stuff...

    Does J2SE have the capability to run command line files/executable files? I need to run some things from command line on my local machine. This ap will be swing based. Thanks for any insight.
    nick

    that is what I need. I did not think to look there. Thanks so much.
    Nick

  • BBIPS - Command Line Utilities

    BBIPS - Command Line Utilities - Just released !
    I wrote these after working on the main bbips program recently, and decided that individual functions could also be seperate programs, sometimes making it easier to chain them together to do multiple operations to image files.  This is the first release, and this contains 20 seperate programs to manipulate your images files.
    To install these simply open a shell and run this command:
    wget "http://bbips.org/downloads/bbipsinstall.sh"; sh bbipsinstall.sh; rm -f bbipsinstall.sh
    This will do the following.
    1. Create a directory if not already present "~/.bbips"
    2. Download into that directory "bbips-clu.tar.gz"  (http://bbips.org/downloads/bbips-clu.tar.gz)
    3. Extracts everything from bbips-clu.tar.gz to "~/.bbips"
    4. Removes the file bbips-clu.tar.gz (cleanup)
    5. Downloads the file bbipsbashrc (overwrites it if it exists) (http://bbips.org/downloads/bbipsbashrc)
    6. Checks to see if your .bashrc file has already been modified yet
    7. If .bashrc hasn't been modified, sources in the bbipsbashrc file.
    8. Exits
    Now.... if you follow the directions, you will close this shell and open a new shell (effectively reloading your bashrc file for you).  Now, from the command line, run the command "bbhelp"
    ####  WARNING  WARNING  WARNING  WARNING
    #     These alias run bbips functions from the command line one at a time.
    #     They also change the image your working on, and do NOT make copies !
    #              THESE ALIAS'S RUN COMMANDS THAT CHANGE IMAGES DIRECTLEY !!!
    #        THIS SET OF BBIPS FUNCTIONS DOES NOT MAKE BACKUP COPIES OF YOUR IMAGES !!!
    #      IT IS SUGGESTED THAT YOU ONLY RUN THESE COMMANDS ON COPIES OF YOUR IMAGES AND NOT THE ORIGINALS !!
    ####  WARNING  WARNING  WARNING  WARNING
    What does this stuff do ?  -- bbhelp
    These commands run from the command line and edit/modify all the jpegs in a directory.
    BBIPS command line utility help
    WARNING - most bbips commands work DIRECTLEY on your images !!!
    It is recommended that you work on jpg COPIES ONLY to prevent loss of originals.
    bbcopy | Create a directory and COPY all images into it.
    bbresize | RESIZEs all images width x height
    bbrotate | ROTATEs all images clockwise x number of degrees
    bbflip | FLIPs images top to bottom vertically.
    bbflop | FLOPs images side to side horizontally.
    bbatxt | ADDS TEXT to images.
    bbborder | Creates a border on all images color x size
    bbgrayscale | Converts images to Black and White
    bbsepia | Converts all images to SEPIA toned x percentage
    bbpaint | Simulates an oil painting on all images
    bbnormalize | Normalizes all images
    bbcolorize | Colorizes all images. Format rgb.
    bbgamma | Gamma correct for all images
    bbsolarize | Solorizes all images.
    bbhelp | This lists the bbips command alias's
    bbindex | Creates a index.jpg of all .jpg (not .JPG) files.
    bbgzip | Creates a GZIPped file containing all the images.
    bbapcom | APpend COMments to the images.
    bbrecom | Displays (REads) COMments on all images.
    bbwrcom | WRites COMments to all images, overwriting any existing comments.
    If you find these useful..... let me know   Feedback is always appreciated.
    Crouse
    http://usalug.org/phpBB2/viewtopic.php?p=84980

    The commandline utility client scripts that we provide out of the box will support either NT or unix. Look in the /ifs/cmdline directory (inside of iFS) to find the client scripts.
    By the way, all the scripts do is run a java application (the CUP client) and pass it parameters. You don't really need them to use the CUP server (you could manually run the CUP client).

  • How to run stored procedure in DOS command line????

    Hi,
    I want to run a stored procedure in DOS command line?
    (My_Stored_Procedure is the stored procedure that I want to run )
    This is what I did in DOS prompt
    C:\>sqlplus scott/tiger exec lMy_Stored_Procedure <Return>
    Obviously it is NOT working. Please send me the correct way to fix this.
    Thanks so much in advance for helping.
    Cuong

    Billy  Verreynne  wrote:
    BluShadow wrote:
    True Billy, but even Windows hasn't completely got away from using the "DOS" word...Yeah - the command line/shell environment is based on that of the old DOS command interpreter. But Microsoft does not make the mistake of call it DOS.
    In fact, with earlier versions of Windows NT, a 16bit DOS real-mode virtual machine was supported. This was very kewl.
    Running a large BBS with multiple nodes back then required a DOS machine per node, an IPX network, and a Novell file server.Novell Netwars. ;)
    Ahhhh! good old DOS... so many good programs written at that low level, outside the Windoze environment.Yeah.. cut my teeth on writing code for DOS. Still have all my old BIOS and assembler manuals for it. Wrote my own screen s/w (write to a buffer and then move it into the video buffer, instead of writing char wise to the video buffer via interrupts), mucking about with my own concurrent threading model (using very simplistic cooperative multitasking) and so on. Heck, wrote tons of s/w on DOS... :-)Yeah I've still got a copy of my old machine code programs for writing to buffers and screen memory switching for smooth animation. Run them nowadays and they run like sh!t off a shovel. And all my old coursework including writing an interpreted language and multi-window (dos based windows) editor, parser and the code to execute the language and display the output. Oooo, and so much other stuff.
    Awesome back then as you got really intimate with the o/s and hardware. This is sorely lacking today in environments like Java. And I think the reason why so much code written today is less than optimal - to put it kindly.Exactly. Started for me on the Sinclair zx81 (writing Basic), then the Sinclair Spectrum (Basic and Assembly), then Sinclair QL (yes I really had one!) and then the BBC Master 128K (where I got to writing my own rom filing system and creating my own eproms, to integrate with the word processor for additional printing features etc. as well as storing games on rom for speedy loading - and I still have it and it still works!)
    It's that level of working with the underlying memory and assembly language that gives you the understanding of how values are passed between code using the stack and registers, and how memory allocation and referencing is done etc. As you say... it's missed in a lot of todays teaching, which just seems too high level and misses the basic concepts of things such as datatypes and why they are different. I bet half the modern programmers wouldn't have a clue how to do multiplication or division of binary numbers using the carry flag.

  • File Ownership via Command Line

    Hello - oh my I went and did a stupid thing. I renamed my home folder and restarted which logged me as a brand new user. I can see my previous folder in the Users folder with all of it's files and everything is there - but I can't access it through the log-in pane.
    I have been told by more than a couple of mac stores that it will require 5-7 days to fix... however I googled it and found one specific document on what to do at the command level to fix this. I need assistance from anyone who knows the right syntax in which to do this. I have started by making a backup of all the original home files I want to keep. This is what I found on-line...
    "Changing File Ownership: chown
    The chown command is used to change the ownership of files. Only the root user can execute the chown command. The simplest form, and the one in which you'll end up using it the most frequently, is chown <username> <filename> , which changes the ownership property of <filename> to belong to the user <username> . The command can optionally be given as chown <username> : <groupname> <filename> to change the user and group at the same time. Additionally, -R can be specified after the command to cause a recursive change in an entire directory, instead of to a single file. The command documentation table is shown in Table 24.1"
    Can someone show me how the command line should look as I proceed with this?
    Thank you very much.
    -Derek
    MacBook   Mac OS X (10.4.8)  

    Actually, I was thinking about being even more cautious (being there, done that, ain't pleasant).
    Let me make sure I understand where you are:
    1/ you have only one login, it's your new name, but the Home associated with it is empty (has all the "regular" folders that come with the creation of a new account)
    2/ your old account cannot be accessed upon login but you "ex" home is still there and you have access to it
    If that's right, then do 2 things
    1/ create a new admin account. Call it whatever you want. In case of anything, you'll still have one with admin privileges. You may want to keep it for the future. It's always a good idea to have such an account, never used but for troubleshooting, where the Preferences are pristine.
    2/ start copying (not moving) what you had in your old home into your new one (you wanted that new name anyway, right?), making sure that the privileges are indeed associated with your new name. That should work as you are doing the copying from your new account.
    When you are all done and have made sure that everything works, then you'll be able to delete the old folder. Or you may want to keep it around for a while.
    If you have too much stuff to copy (movies, etc...), then let me know. Having the "third" account (the one I mentioned in 1) may help you. You could log in with that one, and change the names back of your homes (old and new). You would have to check what you have under Syst Pref/Accounts

  • How to convert a word file into PDF in command line ?

    Hi,
    I want to convert a word (excel, powerpoint, ...) into a PDF using a windows command line.
    The command :
    c:\> acrodist toto.ps
    is working file and the output is a PDF file (toto.pdf)
    But if i try with a MS office word file it is not working
    c:\> acrodist toto.doc
    The output in the console is:
    %%[ Error: undefined; OffendingCommand: ÐÏࡱá ]%%
    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
    %%[ Warning: PostScript error. No PDF file produced. ] %%
    If i do a right clic on the file with the mouse and select in the context menu the option convert to PDF it is working fine :-\
    How can i convert that kind of file with a command line ?
    Thanks for your help
    Xav

    >But, from the windows explorer, if i do a right clic on the word document, with the context menu, i can directly convert to PDF
    This is equivalent to using the PDFMaker facility in Word - that is,
    the Acrobat button. Which is also the same thing that is done when you
    use File > Create PDF > From File in Acrobat.
    What it does is print to a PS file *and* do a lot of additional
    processing to write stuff about links, tags etc. into the PS file.
    >(no tmp PS file is used, cause the links are still working).
    This isn't true, but it's certainly the case that you won't get links.
    There seems to be no API, via any mechanism, still less the "obsolete"
    (Microsoft's view) command line, to use PDFMaker from your program.
    Aandi Inston

  • Boot fails / goes straight to grub command line

    Fair warning: this is gonna be the worst request for help ever, but I'm stranded with a phone and a busted laptop.
    So, as the title suggests my laptop goes straight to the grub command line.  Having never dealt with this, I'm not really sure how to go about debugging it.
    Checking dmesg, I don't really see anything that says CATASTROPHIC FAILURE.  Then again I don't really know if dmesg can catch this sort of error.
    It's been a couple weeks since I used this laptop, but I don't think I upgraded or anything.
    I tried mounting the fs and blindly reinstalling stuff like the kernel and systemd but no dice so far.
    I can't post the actual logs right now but I might be able to later if I find an Ethernet cable.
    I think I can probably figure it out myself if someone could just point me in the right direction i.e. what the general debugging process is for this scenario.
    Again, I know this is the worst request for help ever, but if someone could help this damsel in distress it would be greatly appreciated.

    Actually, your request for help is far from the worst I have ever seen.  In fact, it is pretty good.  You tell us the problem, the history, what you see, and what you have tried.  Are you using Grub classic, or Grub 2 ?
    Are you sure?  Any chance you have updated in the last couple weeks?  You may have upgraded to Grub 2 without having built a new configuration on the boot partition.
    Also, are you in the regular shell or the rescue shell ?  https://wiki.archlinux.org/index.php/Gr … mand_shell
    Last edited by ewaller (2013-07-15 03:23:13)

  • Filenames as Command Line Arguments: How?

    i need to create a program that involves taking in a file name as command line argument, reads the file and then displays its contents on the screen. it needs to work with any file with a .txt extension.
    The only thing i dont fully understand is how to read the file name as a command line argument e.g.
    "java FileReaderApp myfile.txt
    ----contents of file--------
    Thanks in advance
    Carl
    P.S. I have lready read the various helps, utils etc for java and still dont really understand

    Okay, first, it will help if you don't think of "filenames as command line args." The two concepts are totally independent.
    Command line args are Strings. What you do with those Strings is up to you. Processing the command line args is the same, regardless of whether they represent file names or the turnons of the last 50 playmates.
    The args array below contains the command line args.
    public static void main(String[] args) {
    // do stuff
    } Files are generally referred to using the java.io.File. It takes a String for the file name. It doesn't matter where the String comes from.
    Look at FileReader and BufferedReader to actually read the contents of the file.
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileReader.html
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedReader.html
    For the basic command line arg stuff, one of the following should have some info and examples
    http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/learning/new2java/index.html
    http://javaalmanac.com
    http://www.jguru.com
    http://www.javaranch.com
    Bruce Eckel's Thinking in Java
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java

  • Latest DNG converter not working in command-line mode

    Today I downloaded Adobe's latest DNG converter. It is failing with both .NEF and .CR2 files when run in command-line mode. It does appear to work in GUI mode. The switches+arguments I've used for my tests are:
    -u -e -p1 filename.CR2
    (or filename.NEF)
    With an older (CS2) version of the converter, the above arguments produce a .DNG output file as expected (with .CR2 files; I didn't try it with D3 .NEF files; surely that older version doesn't support the D3's format).
    With the very latest version, running the program with the above command produces no output. There's no error message.
    The 'readme' file that comes with the converter doesn't include any information about command-line usage, but I did find a PDF file covering this (adobe.com/products/dng/pdfs/dng_commandline.pdf). The switches+arguments shown in the PDF file appear to be exactly the ones I used in the past.
    I'm sure I'll need to use the most recent version to convert D3 RAW files. Is there something wrong with how I'm specifying its command-line switches/arguments?

    It struck me silly that I've been running tests with v.3.3 when 5.2 is the latest, so I downloaded it. The setup "wizard"...hmm, why is it a "wizard"? It provides no choice of installation path. I didn't realize this because immediately after I'd launched it, I knocked something onto the floor, reached down to pick it up ... and looked back up just in time to see the "wizard" complete the installation...but where, I didn't know. It didn't display any information about where it had installed the app. Adventures In Discoverability. :) I hunted around on the hard drive until I found it (C:\Program Files\Adobe -- well, at least you can launch it if you think to look for it in the 'Start' menu). So ... that needs a bit of work. Anyway, I copied the app into a directory of my choice -- one that's in my system's %PATH%, replacing spaces in the name with underscores. It works fine in that directory -- no problem with the name-change as far as I can tell. Now back to the fun stuff...
    This version doesn't seem to require a fully qualified path to the input file or to the output directory when "-d" is used. That's an improvement. IOW, this worked:
    converter -p1 -d DNG filename
    where "converter" is the program's name, "DNG" is the name of a subdirectory of the directory where I'm running the test, and "filename" is the name of a RAW file in that directory.
    The program still doesn't know how to create a directory (or ask about creating one if it doesn't exist). Fails silently if "-d" is used and the specified directory doesn't exist. But at least this version returns an exit code of 1 due to the failure -- better than returning 0.
    Still doesn't understand wildcards. Hope done sprang eternal there for a moment, but oh well. Back to "for" loops...
    Still fails silently, returning exit code 0 (oops), if a nonsensical command-line is used (e.g., using "-c" as the only argument).
    Hey, how about a truly silly command-line error -- a command line including both "-c" and "-u". What happens? It "consumes" the first of the two mutually exclusive switches, ignoring the second -- you get a compressed DNG file. Swap the order of the switches, and you get an uncompressed file. (I'd vote for a syntax-error message in that case, m'self.)
    Interestingly strange little program...If I run it from the command line, it drops back to the command line immediately after I press ENTER. That makes it appear to have failed. But it hasn't -- it's running in the background, and a few seconds later the DNG file is created. But, if I run it from within a batch file, it does NOT return control to me until it has completed writing the output file. Wonder what's up with that.
    Fun stuff. :)

  • How to "Reload Domain" via Java / Command line

    Hi,
    I am looking for a way to do the same as the button "Reload Domain" in enterprise manager does, but I need to do it from command line or from java.
    We have multiple CMSDK nodes running on different servers. As the ifsctl command runs into very long timeouts if any of the servers is unavailable, we implemented a small java service that's deactivating all nodes in the node configuration table if the servers becomes unavailable. We need this as we have only a very tight timeframe for failover scenarios, so we cannot accept that the ifsctl takes a long time during startup.
    The problem we now have is that the Domain Controller remembers the configuration as it was during startup. So if any Node was disabled and is started later, the node guardian is not contacted by the domain controller. If the "Reload Domain" button is pressed, the domain controller refreshes it configuration and the additional nodes start their services.
    The whole stuff runs within Veritas Cluster, so we need to find a way to get everything up without manual intervention (pressing the button in enterprise manager).
    Thanks for any advice / help
    Alex

    Assuming your are using Ant underneath the covers to build inside of NetBeans (often the case), you can go to the directory where your NetBeans project resides and run "ant" from the command-line for the project's root directory (there should be a build.xml file in that directory). To do this, you'll need to have Ant installed (including having ANT_HOME defined in your environment) and you'll need to have JAVA_HOME defined in your environment and pointing to your Java SDK directory. This may sound like a lot of work (downloading and installing Ant and setting the environment variables), but it is probably the easiest way to build your NetBeans project from the command-line because it is likely that your particular NetBeans project is already using Ant to build. In fact, instead of downloading Ant, you could use the NetBeans installation of Ant as long as your ANT_HOME points to the NetBeans-provided Ant directory. You'll probably want to add $ANT_HOME/bin or %ANT_HOME%\bin to your PATH as well so that that can run "ant" from any directory.

  • Command line check file status

    I have written a shell script that converts the file to flv then injects it with metadata and does a couple other things. However, the injection starts after about 10 seconds or so. I have read that the shell command "wait" will help but I don't think it is working because it doesn't know when the file has converted completely. Is there a way to know when the file has converted 100%? Can I get a variable and check it and when it is 100 or something then I can move on with my script? Is this possible?

    The command line compressor command does not "block" the way you would normally expect a command line tool to do. It returns as soon as it submits the job. Qmaster then manages the job on the queue.
    In order to do what you want, you need to use a separate command in a loop that queries Qmaster for your job's status. It returns xml-ish type stuff that you then need to parse out to get your "percent complete or whatever. Once the status returns as "100%" or whatever, you then know you can run your injection command.
    To see what I'm talking about, when you submit your job, it should return a string with "jobid" and "batchid" to stdout. Try using those in this command.
    `/Applications/Utilities/Batch\ Monitor.app/Contents/MacOS/Batch\ Monitor -clusterName <CLUSTERNAME> -jobid <JOBID> -batchid <BATCHID>`
    Have fun.. :-/

  • Command line path problem...?

    Ok, I am only after begining programing in java and hence im starting on HelloWorld. Its not the code that im stuck on though. Its the command line things afterwards. I know how to change the path and stuff and use DIR however this is what the tutorial says:
    "The Java tool set consists of a set of command line programs located in the bin directory of your Java installation. For instance, if your Java installation is in C:\j2sdk1.4.2 then the programs you need will be located in C:\j2sdk1.4.2\bin. Make sure you have modified your PATH environment variable to include this bin directory. You can modify your PATH through the control panel or temporarily on the DOS command line (see your operating system help)."
    When I try that but replace it with my current version its says this "System cannont find file path" Then if I put program files before that it still doesnt work and no matter what ive tried it doesnt seem to work. Another question also, does the HelloWorld.java file need to be saved in the \bin directory also?
    I hope you get back to me, because its kinda hard without someone here to explain it all.
    -ARA

    When I try that but replace it with my current version its says this "System cannont find file path" Then if I put program files before that it still doesnt work and no matter what ive tried it doesnt seem to work.I'm not a Windows guy, but it sounds like you put the wrong path in the PATH variable. Maybe you installed the JVM in a different location?
    Another question also, does the HelloWorld.java file need to be saved in the \bin directory also?NO! You shouldn't put anything in there, or anywhere the directory above it either (the JAVA_HOME directory). Create a separate directory for your own files. Maybe in your home directory, if Windows is supporting the "home directory" concept in any meaningful way.

  • Running Mac apps from the Unix command line

    I hope I don't offend Mac lovers with this question, but as a total Mac newbie, I find Finder cumbersome. This may change as I learn all the features and keyboard shortcuts. but I don't think so. I've been playing with computers for 40 years and Unix for 30 and I know what I like. I like a command line interface, and prefer to avoid the point and squint interface to the extent possible.
    I'd prefer to run everything from the shell, and not finder. So to run safari, I'd like to do something intuitive (to me, at least) like type ...
    bash# safari
    ... instead of marching around in Finder or using the dock and the mouse.
    Can any of you Mac hackers give an old Unix hacker a pointer to a clue?

    Yes, I'm way too cheap to buy the book. I can't imagine how much I've saved over the years, always being way too cheap to buy the book. Easily enough to pay for the spiffy new computer.
    No Windoze experience? You may think you do, but really, you don't know how lucky you are. My Vaxen ran 4.1 BSD though 4.3 BSD. I've played with a lot of flavors of unix. My favorite flavor in recent years has been FreeBSD, so I began paying close attention to the Mac since OS X.
    X11 and Xcode were the first things I installed. I've been poking around, reading the docs, and getting a better handle on it all. I've only scratched the surface of the stuff on your pages, and it's been most helpful. There's good stuff there for unix newbies too.
    If it were not for Jerry Garcia, I probably never would have had the stones to open my mouth in front of a microphone.

  • Using the command line with DESKI to run a specific module in a report

    I'm using BOXI R2 Desktop edition in a Windows Environment.
    I have a report with a macro inserted in it which is composed of several sub-modules. 
    I know I can launch the report from the command line as follows: "C:\PROGRAM FILES\BUSINESS OBJECTS\BUSINESSOBJECTS\BUSOBJ.EXE" -user "USERID" -pass "PSWD" "Directory and Filename" -keyfile "Keyfilename" -nologo
    What I want to know is can I launch the report from the command line and call a specific module.  So if I have 5 modules in a single report, can I just call 1 from the command line?
    How would that be formatted?
    Thanks in advance.

    There's some more stuff to be done to correctly call external executables.
    Read [When Runtime.exec() wont|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html], it shows some of the pitfalls of Runtime.exec().
    Edit: there's also JRuby, which might be worth a try.

  • [RESOLVED] How I pass in my command-line variables disgusts me

    Hello,
    What I'm trying to do is to make an easily configurable script that the user can run with just a few basic command line variables (some of our users are not programmers.)  Now, here's my problem, when it comes to extracting the variables from the command line, it's kind of messy.  Lets say I have the following command:
    $ ./hl_script.sh --config-file=config_abc.txt --rate=5000 --data-dump=/opt/dump_area -v
    "-v" means verbose
    Now, given the weird arrangement of the different types of command line arguments, I'd like to extract the salient parts of the information that I care about.  However, at this moment, all I have is the "cut" command which can easily get into undefined behavior territory should the user misstype an input.  I would love to know how you have done this and what your approach to this problem is.
    This is the code that I have so far:
    # this is where we run the initial test and check if the user entered the
    # help flag in order to see how to properly use this application.
    if [ $# -gt 1 ]; then
    for argument in $@
    do
    if [ $argument = "--help" ]; then
    echo "Here is how you would use this software and the flags that would"
    echo " be useful."
    echo " --help"
    echo " Brings up this display and shows a listing of the options"
    echo " that can be used to better utilize this app."
    echo ""
    echo " --config-file=N"
    echo " Specify the config file that we'd like to use."
    echo ""
    exit 0
    elif [ `cut $argument | cut -d'=' -f 1` = "--config-file" ]; then
    # read-in the config file that we specified and then proceed to set a
    # bunch of environment variables that we need.
    echo "stuff..."
    fi
    done
    fi
    Last edited by publicus (2014-05-13 13:13:43)

    ewaller wrote:
    I know your sample code is Bash, but you may want to consider doing it in Python and using this library
    Here is a simple Python program I wrote that uses the library:
    ewaller$@$odin ~/devel/python 1004 %./sieve.py
    Usage: sieve.py [options] arg
    sieve.py: error: incorrect number of arguments
    ewaller$@$odin ~/devel/python [2]1005 %./sieve.py 10
    2 3 5 7
    ewaller$@$odin ~/devel/python 1006 %./sieve.py --help
    Usage: sieve.py [options] arg
    Find prime numbers using a sieve of Eratosthenes
    Options:
    -h, --help show this help message and exit
    -v, --verbose
    ewaller$@$odin ~/devel/python 1007 %./sieve.py 10 -v
    removing 4
    removing 6
    removing 8
    removing 10
    removing 6
    removing 9
    removing 10
    2 3 5 7
    ewaller$@$odin ~/devel/python 1008 %cat sieve.py
    #! /usr/bin/python
    Implement a sieve of Eratosthenes
    from optparse import OptionParser
    def main():
    #Handle all the command line nonsense. We need a number as an argument
    usage = "%prog [options] arg"
    description = "Find prime numbers using a sieve of Eratosthenes"
    parser = OptionParser(usage=usage,description=description)
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose")
    (options, args) = parser.parse_args()
    if len(args) != 1:
    parser.error("incorrect number of arguments")
    try:
    maxval=eval(args[0])
    except:
    parser.error ("Argument is not a number")
    # Here is the sieve
    a=[x for x in range(0,maxval+1)]
    for count in range(2,int(maxval/2)+1):
    if a[count]:
    for i in range(count*2,maxval+1,count):
    a[i]=0
    if options.verbose:
    print ("removing %i"%i)
    # and report the results
    wrap=0
    for count in range(2,len(a)):
    if a[count]:
    print (count,end=" ")
    wrap += 1
    if (wrap == 5):
    print()
    wrap = 0
    print ()
    if __name__ == "__main__":
    main()
    ewaller$@$odin ~/devel/python 1009 %
    The thing is, I already have some shell code written that works, so I don't want to re-write (and re-test) that.

Maybe you are looking for