ArtinSoft's Blogs

Software Migration Experts
Welcome to ArtinSoft's Blogs Sign in | Join | Help
in Search

Mauricio Rojas Blog

February 2007 - Posts

  • smbclient

    I like Linux and consider it as a very interesting OS alternative
    However sometimes there are simple things that I just do not know how to do.
    Windows is still everywhere and specially getting thing
    from a Windows to a LINUX box can be tricky.
    For example recently I had to restore a database
    from a Windows DB2 to a Linux DB2 so I had the backup and needed to
    eove it to the linux box.
    So use smbclient!
    But how.
    Ok.
    to connect to a windows share do something like this:

    smbclient -user domain/username //machine/sharename

    this thing will ask for your password and now you are connected.
    Smbclient is just like an ftp.
    But how do you copy a directory
    I found these instructions in the internet:

    smb: > tarmode
    smb: > lcd /tmp
    smb: > recurse
    smb: > prompt
    smb: > mget your_directory/

    as simple as that.
    So hope that helps

    Posted Feb 22 2007, 11:04 PM by Mrojas with no comments
    Filed under:
  • Printing in Java

    Sample Code to Print in Java

    import java.io.ByteArrayInputStream;
    import javax.print.Doc;
    import javax.print.DocFlavor;
    import javax.print.DocPrintJob;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.SimpleDoc;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;

    public class Class3 {

    static String textToPrint = "Richard North Patterson's masterful portrayals of law and politics at the apex of power have made him one of our most important\n" +
    "writers of popular fiction. Combining a compelling narrative, exhaustive research, and a sophisticated grasp of contemporary\n" +
    "society, his bestselling novels bring explosive social problems to vivid life through characters who are richly imagined and\n" +
    "intensely real. Now in Balance of Power Patterson confronts one of America's most inflammatory issues-the terrible toll of gun\n" +
    "violence.\n\n" +
    "President Kerry Kilcannon and his fiancée, television journalist Lara Costello, have at last decided to marry. But their wedding\n" +
    "is followed by a massacre of innocents in a lethal burst of gunfire, challenging their marriage and his presidency in ways so shattering\n" +
    "and indelibly personal that Kilcannon vows to eradicate gun violence and crush the most powerful lobby in Washington-the Sons of\n" +
    "the Second Amendment (SSA).\n\n" +
    "Allied with the President's most determined rival, the resourceful and relentless Senate Majority Leader Frank Fasano, the SSA\n" +
    "declares all-out war on Kerry Kilcannon, deploying its arsenal of money, intimidation, and secret dealings to eviscerate Kilcannon's\n" +

    "crusade and, it hopes, destroy his presidency. This ignites a high-stakes game of politics and legal maneuvering in the Senate,\n" +

    "the courtroom, and across the country, which the charismatic but untested young President is determined to win at any cost. But in\n" +

    "the incendiary clash over gun violence and gun rights, the cost to both Kilcannons may be even higher than he imagined.\n\n" +

    "And others in the crossfire may also pay the price: the idealistic lawyer who has taken on the gun industry; the embattled CEO\n" +

    "of America's leading gun maker; the war-hero senator caught between conflicting ambitions; the female senator whose career is at\n" +

    "risk; and the grief-stricken young woman fighting to emerge from the shadow of her sister, the First Lady.\n\n" +

    "The insidious ways money corrodes democracy and corrupts elected officials . . . the visceral debate between gun-rights and\n" +

    "gun-control advocates . . . the bitter legal conflict between gun companies and the victims of gun violence . . . a\n" +

    "ratings-driven media that both manipulates and is manipulated - Richard North Patterson weaves these engrossing themes into an\n" +

    "epic novel that moves us with its force, passion, and authority.";

    public static void main(String[] args) {

    DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;

    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();

    /* locate a print service that can handle it */

    PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);

    /* create a print job for the chosen service */

    int printnbr = 1;

    DocPrintJob pj = pservices[printnbr].createPrintJob();

    try {

    /* * Create a Doc object to hold the print data.

    * Since the data is postscript located in a disk file,

    * an input stream needs to be obtained

    * BasicDoc is a useful implementation that will if requested

    * close the stream when printing is completed.

    */

    ByteArrayInputStream fis = new ByteArrayInputStream(textToPrint.getBytes());

    Doc doc = new SimpleDoc(fis, flavor, null);

    /* print the doc as specified */

    pj.print(doc, aset);

    }

    catch (Exception ex){

    ex.printStackTrace();

    }

    }}

     

    TIP: If you are just testing create a Printer. Just go to Add Printers, select FILE for port and Manufacturer Generic and TEXT Only

    Posted Feb 02 2007, 04:20 PM by Mrojas with 1 comment(s)
    Filed under:
Powered by Community Server (Non-Commercial Edition), by Telligent Systems