Printing Command-Line results

Hello,
I need help printing the results from a command line operation. For example, I was to iterate through all the users on our (linux) server and store some info in a DB. How to I execute the command from within my code?
Thank you greatly, your help will be appreciated...

Establish your database connection, then iterate through each user (although I don't know how your going to get each user name unless you go through the passwd file, but eh... ) and execute a com-line op similar to:
Process proc = Runtime.getRuntime().exec("grep '" + username + "' /etc/passwd");
BufferedReader reader =
    new BufferedReader(
    new InputStreamReader(
    proc.getInputStream()));this will let you read through every line of the result.
Similarly, if you wanted to list all the files in some directory, you'd replace the 'grep' command by 'ls directory'
Good luck

Similar Messages

  • Getting and printing command-line arguments

    (char *)curpsinfo->pr_psargs will give me the "first part of the command line",
    but that has two deficiencies:
    1. If the command line is long, it might get truncated.
    2. If the command line contains white space, I have no way to know whether the
    spaces in the string are part of an argument ot separation. That is, I can't tell
    "ls 'foo bar' baz" from "ls foo bar baz"
    I want to get the individual arguments, so that I can print them as run-length encoded strings:
    cmd=7:/bin/ls
    a1=7:foo bar
    a2=3:baz

    I've reworked your script:
    inline int TGT_PID = $1;
    BEGIN { /* 1 */
            printf("BEGIN\n");
            mypids[TGT_PID]++;
    syscall::exece:entry /* 2 */
    /mypids[curpsinfo->pr_ppid] != 0/ {
            self->follow = 1;
    syscall::exece:entry
    /(self->follow != 0) &&
    (this->argp = (uintptr_t)(curpsinfo->pr_dmodel == PR_MODEL_ILP32 ?
        *(uint32_t *)copyin(arg1 + 0 * 4, 4) :
        *(uint64_t *)copyin(arg1 + 0 * 4, 8))) != NULL/
            a1 = copyinstr(this->argp);
            a1_l = strlen(a1);
            printf("a1=%d:%s\n", a1_l, a1);
            this->last = 1;
    syscall::exece:entry
    /(self->follow != 0) && this->last == 1 &&
    (this->argp = (uintptr_t)(curpsinfo->pr_dmodel == PR_MODEL_ILP32 ?
        *(uint32_t *)copyin(arg1 + 1 * 4, 4) :
        *(uint64_t *)copyin(arg1 + 1 * 4, 8))) != NULL/
            a1 = copyinstr(this->argp);
            a1_l = strlen(a1);
            printf("a1=%d:%s\n", a1_l, a1);
            this->last = 2;
    syscall::exece:entry
    /(self->follow != 0) && this->last == 2 &&
    (this->argp = (uintptr_t)(curpsinfo->pr_dmodel == PR_MODEL_ILP32 ?
        *(uint32_t *)copyin(arg1 + 2 * 4, 4) :
        *(uint64_t *)copyin(arg1 + 2 * 4, 8))) != NULL/
            a1 = copyinstr(this->argp);
            a1_l = strlen(a1);
            printf("a1=%d:%s\n", a1_l, a1);
    }The way I debugged this was by figuring out the action that was causing the error by removing actions and then examining its arguments. In this case, you were using the curpsinfo which had the arguments before exece(). You actually wanted to use arg1 as you had before which a char ** NULL-terminated array of arguments.
    Since it's a NULL-terminated list, I added the this->list stuff so I didn't walk off the end of the list.

  • Linux acroread 8.1.2 can't change print command

    It won't let me do it and it won't let root do it.
    I use cups and don't use lpr

    >This (making the print command line un-editable) is really bad idea.
    Why? It was much worse before, since people would edit it, but it had
    no effect. This is terrible interface design, and surely this is an
    improvement.
    > add a "expert option"-Button "Make the print command line editable"
    Or an option "Give me an editable area that will be ignored". Why?
    It could probably be improved so more people understand that if they
    want to print with a custom command line, then they need to choose
    Custom. Perhaps best of all would be keeping a custom command for each
    printer, or an open ended set of commands (so, for example, two custom
    commands for one printer could be stored).
    Aandi Inston

  • Adobe XI remains open after printing from command line

    I am using a program to collect, batch print and delete multiple PDF files.
    The following command line is used to print the files, after which the file is deleted and next file is collected.
         "C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe" /T /N FileName.pdf
    I have now upgraded to Adobe XI, however Adobe remains open (and minimized) after sending the print job to the printer, resulting in my programing freezing while waiting to delete.
    Is there a parameter to close Adobe after printing?
    This is rather urgent as we have started rolling out the new Adobe XI.
    OS = Windows7 Prof x64

    Command line parameters are sparsely documented and are officially not supported. What is documented can be found here: http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/intro_to_sdk/DeveloperFAQ.pd f
    I've not seen anything that shows what you want to do.

  • How can I print the test page with the Arabic type from the command line

    Hi,
    I have been trying to make the tool for printing the test page from the command line on the Arabic OS. I used "rundll32 printui dll printuientry" with "/k /n" options. My tool is to print the test page in all OS when pushing the
    button.
    Normally, in the Arabic Windows, the test page is printed with RTL type when printing the test page in the "Devices and Printers". But in my tool, the test page is printed with LTR type. I'm confused because of this result.
    Is it possilbe to print the test page with RTL type when using the "rundll32 printui dll printuientry"? If it is possible, could anyone give me the hint or information for resolving?
    Please check for me.

    Hello,
    Thank you for your post.
    Your issue is out of support range of Test Tools in Visual Studio 2010 and 2012 forum which discusses Visual Studio Test issues.
    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • CUPS print job options fail when called from lp (UNIX command line)

    Under Leopard this command-line print request fails to respect the specified job options:
    lp -o number-up=2 -o page-border=double <filename>
    Though it worked great in Tiger, the number-up and page-border job options are now disregarded. I have tried lots of things (and wasted lots of paper) such as setting them permanently with lpoptions (and they do appear changed when the lpoptions command is repeated), using lpr instead of lp, reinstalling the printer via the CUPS localhost web interface, enabling non-Bonjour scanning with the hack to the CUPS preference file, deselecting "Last Printer Used" for the default printer in the System Preferences -- nope.
    I have not tried other job options; I assume that whatever is breaking these two is breaking all the others, and even if it isn't, these two are what I want.
    Is something new in Leopard overriding lpoptions job options? How do I make it stop? It is sooooo aggravating when something that used to work fine breaks. The printer is an HP LaserJet 4000N connected by Ethernet and discovered with AppleTalk.
    Thanks for any advice!

    Thanks John, I did search but somehow missed that thread.
    However it did not help. With or without the "-p printername" argument lpoptions does make a persistent change to its own data:
    +$ lpoptions+
    +media=Letter sides=one-sided finishings=3 copies=1 job-hold-until=no-hold job-priority=50 number-up=2 auth-info-required=none job-sheets=none,none printer-info=Barrow printer-is-accepting-jobs=1 printer-is-shared=0 printer-location='Local Zone' printer-make-and-model='HP LaserJet 4000 Series' printer-state=3 printer-state-change-time=1209495301 printer-state-reasons=none printer-type=2134228 page-border=double+
    You can see that the printer "Barrow" has remembered "number-up=2" and "page-border=double". Regardless if I give any of these commands:
    +lpr <filename>+
    +lpr -P Barrow <filename>+
    +lp <filename>+
    +lp -d Barrow <filename>+
    none of them show the results of these option settings (and somewhere in the forest another tree is cut down).

  • How to print a specific page from a given PDF document, using command line, please?

    Hello,
    I need your advise, please. My customer requires to print a specfic page from a pdf document they receive, using command line or 3rd party solution.
    Anything you can advise, please? I have seen AcroRD32.exe options, but can only print the whole document.
    Kind Regards

    Not sure if there are any examples. The Acrobat SDK is a must, but it is best treated as documentation to study rather than examples to copy. The examples only illustrate a tiny fraction of the capabiliies.
    (One other note: the solution must involve the client owning Acrobat; Acrobat is not for server use).

  • We are trying to implement a process so that any document that needs to be printed through our Java application will be printed as PDF using Adobe Reader. For which, We created and execute the below command line to call Adobe Reader and print the PDF on a

    We are trying to implement a process so that any document that needs to be printed through our Java application will be printed as PDF using Adobe Reader. For which, We created and execute the below command line to call Adobe Reader and print the PDF on a printer."C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /T "\\<Application Server>\Report\<TEST.PDF>" "<Printer Name>". Current Situation: The above command line parameter when executed is working as expected in a User's Workspace. When executed in a command line on the Application Server is working as expected. But, the same is not working while executing it from Deployed environment.Software being used: 1. Adobe 11.0 enterprise version. 2. Webshpere Application Server 8.5.5.2. Please let us know if there is a way to enable trace logs in Adobe Reader to further diagnose this issue.

    This is the Acrobat.com forum.  Your question will have a much better chance being addressed in the Acrobat SDK forum.

  • Is there a way to print/convert a file to PDF from the Command Line? If so, how?

    I'm trying to do something that I imagined would be really simple, but I haven't found a good resource on how to thus far. I'm trying to do something along the lines of this:
    Acrobat.exe /print inputfile.xls outputfile.pdf.
    Does anything like this command exists?

    For automating Acrobat there are many interfaces for programmers, but no command line like that. (Microsoft declared command lines dead almost 20 years ago, but they've been an unconsionable time a dying).

  • Can I print the last page of a PDF document using command line?

    Hi
    I am in a situation in which I constantly have to deal with multiple PDF documents and I need to print the last page in each of these, and ONLY the last page. The total number of pages will vary for each file, so the page number for the last page will also vary.
    I would really prefer to not do this manually, by opening up each file in the visible Adobe Reader window and then print.
    Question:
    Is there a way with Adobe Reader (maybe with the help of some other Adobe product) to print only the last page of a PDF document using some kind of command line without opening up the PDF file in the visible Adobe Reader window?
    I'm using Windows.
    Thanks in advance,
    Regards,
    Emil

    Thank you for taking the time to reply.
    I tried both ways and neither works.  It gives me a prompt box that I have to click "next" for every page but after going thru all pages, nothing is sent to the printer.
    Also, all directions I've read indicate it will print to the default printer.  If my default printer is on a network, will that cause problems....
    and...
    should I be getting a prompt box on every page?  I thought all this would happen behind the scenes and not force me to interact with every page.
    dc

  • Command line parameters to print to a file

    Hello
    is there a command line parameter for acrord32.exe to specify a filename to print to - just as if i ticked the box in the print dialog to print to a physical file?
    If not does anyone know how i can do that?
    Thanks
    Sean

    Asserts are disabled by default. Use the -ea switch to enable asserts or -da to explicitly disable them.
    You can find documentation about the assertion facility at http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html
    Remember, the Java Docs http://java.sun.com/sun/ are your friend!

  • Can i print a file using thunderbird with command line switch

    Trying to automate printing task. I have a folder with 1000's and 1000's of eml files that need to be printed using thunderbird.
    I am able to get the command line switch to open the file in thunderbird.
    But what i really want is to print these files directly using thunderbird without opening the file in GUI.
    Thanks
    Dennison

    ส่งจาก จดหมายของ Windows
    จาก: Pat Willener
    ส่งเมื่อ: จ. 5 มกราคม 2558 6:15
    ถึง: thang dinhvan
    How can I print a file with mixed page orientation in windows 8.1?
    reply from Pat Willener in Adobe Reader Touch for Windows 8 - View the full discussion 
    I have a win 7 and a win 8.1 computer.  I have a file which contains both landscape and portrait pages.  The file prints correctly with the mixed orientation from the win 7 pc, but will only print with either landscape or portrait on the win 8.1 pc. 
    I am using Adobe reader XI on the win 7 pc and adobe touch on the win 8.1 pc
    If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7064031#7064031 and clicking ‘Correct’ below the answer
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7064031#7064031
    To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
    Start a new discussion in Adobe Reader Touch for Windows 8 by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • Reader 10.1.4. Printing PDF by command line

    Hi
    In an application I have developed I print PDF files to a defined printer using command line, such as
    "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\acrord32.exe" /N /T "myPDFfile.pdf" "\\servername\printername"
    I have noticed a change of behaviour with Reader 10.1.4 to previous versions.
    To test locally I share a local printer (e.g. share name "bobsprinter") connected to my machine ("bobsmachine") and include it in the command line as follows
    "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\acrord32.exe" /N /T "myPDFfile.pdf" "\\bobsmachine\bobsprinter"
    I have noticed that with Reader 10.1.4 a print job is no longer submitted, unless I take out the machine name and just leave in the shared printer name:
    "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\acrord32.exe" /N /T "myPDFfile.pdf" "bobsprinter"
    Where it then works OK.
    Question: Why would there be this change of behaviour in 10.1.4? Is there anything I need to consider? I have not come across anything in the release notes.
    I have noted that on my customer's site my command line (with machien and printer name) still works OK with 10.1.4. Maybe because the shared printer is on another network?
    Many thanks in advance.

    Hi Bob,
    Thanks for reporting the problem faced by you. My investigations suggest that command line printing behavior between Reader 10.1.3 and 10.1.4 is still the same.
    It prints the document on Reader 10.1.3 and 10.1.4 only when you do not specify the servername(localhost) on command line. However, It prints both with/without using the servername when Acrobat is used.
    Thanks,
    Atul Agarwal
    Adobe Systems

  • Best way to save XML results to a file via command line

    I'm trying to set up an easy way that I can save my XML results to a file via the command prompt.
    Here's my current command line statement
    sqlcmd -S server/database -E -i C:\XML.sql -o C:\Test.xml -h -1 -m 1 -y0
    That works about 95% of the way. The problem is it still inserts a couple random line breaks and throws my whole XML off.
    The whole idea of doing this via the command line is because it would be nice to link it to a batch file that runs every so often. Is there a better way to execute a SQL statement and have its contents saved properly to an XML file?

    If I copy and paste the result via SSMS into a file and save it as an XML, I can view it properly in browsers. If I use the code above, I get among other errors: 
    This page contains the following errors:
    error on line 2 at column 202: Encoding error
    The XML file gets processed in a 3rd party app. The file that I paste directly works fine, but the file that the script produces generates errors and it won't work.

  • Print using command line

    Hello experts,
    As mentioned in http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm we can use command line instruction to open a pdf file in Acrobat Reader and print it.
    Does anyone know if this works both in Windows and in UNIX?
    Thank you.
    Gie Kian Siauw

    Hi Gie,
    On Unix, you can use commandline instruction to create ps files from the pdf files.
    for eg. "acroread -toPostScript -pairs a.pdf a.ps"
    You can also pipe the ps output to a printer.
    for eg: "acroread -toPostScript -pairs a.pdf - | lp -d <Printer Name>
    This is a headless process of printing pdf files without the launching of acroread.
    The file is not opened in the acroread and just printed.
    Regards,
    Rishi

Maybe you are looking for