Configure RDP on Fedora 24

logo_fedoralogoContext
You would like to connect to your Fedora Workstation 24. You could install the protocol xrdp and configure the connection based on your needs.

1. Install and enable xrdp

# dnf install -y xrdp
# systemctl enable xrdp.service
# systemctl restart xrdp.service

2. Configure the keyboard

# cd /etc/xrdp
# setxkbmap -layout be
# cp km-0409.ini km-0409.ini.bak
# xrdp-genkeymap km-0409.ini

3. Configure the language

# nano /etc/environment
LANG="fr_BE.UTF-8"

4. Enable the language

# nano /etc/xrdp/startwm.sh
. /etc/environment

Replace Text on Solaris

aktualne_logo_oracle_solaris_os_ososContext
You would like to replace a text string for a bunch of files. You could use the “find” and the “perl” command to achieve it.

1. Make a backup of the directory

cp -r /soft/applications/corona/scripts/pars /soft/applications/corona/scripts/pars.bak

2. Replace the text string to the files

find /soft/applications/corona/scripts/pars -type f -name "*.par" | xargs perl -pi -e 's/password=install/password=installint/g'

3. Check the change

grep -i  "password=" /soft/applications/corona/scripts/pars/*

replace-string

Migrate Solaris Data

aktualne_logo_oracle_solaris_os_ososContext
You would like to migrate data from one Solaris server to a new one. The destination server contain already data and you need to keep the existing files on it. You could use the command “rsync” to do a full copy to the new one without loosing information.

  1. Test your data migration
    rsync --dry-run --ignore-existing -rvh --progress /mnt/ /soft/applications/corona
  2. Once your are ready, start the synchronization
    rsync --ignore-existing -rvh --progress /mnt/ /soft/applications/corona

    2016-10-19-10_25_43-be-s0492-msa-adroot-local-putty

Run VM on Desktop

qemu-logoContext
You would like to run a VM on your desktop without any administrator right. You could use the open-source hypervisor QEMU to execute your favorite Windows Server.

  1. Download and extract the application QEMU2016-10-05-15_19_48-c__temp_qemu2-7
  2. Execute a command prompt and change to the directory2016-10-05-15_21_48-c__windows_system32_cmd-exe
  3. Create the filesystem for the OS (Windows Server 2008 R2)
    qemu-img.exe create windows2008r2 50G
  4. Download the virtio-win iso and Windows Server 2008 R2 into the directory
  5. Run the installation with the virtio drivers
    qemu-system-x86_64.exe -drive file=windows2008r2,format=raw,cache=none,if=virtio -boot d -m 2G -smp 2 -numa node,nodeid=0 -numa node,nodeid=1 -localtime -usb -usbdevice tablet -cpu SandyBridge -net nic,macaddr=B4-B5-2F-AB-C4-CA,model=virtio -net user -balloon virtio -vga std -drive file=virtio-win-0.1.118.iso,index=0,media=cdrom -drive file=7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso,index=1,media=cdrom

    N.B. configure -cpu and -net value (MAC cloning)

  6. Boot the server and install the drivers + guest agent
    qemu-system-x86_64.exe -drive file=windows2008r2,format=raw,cache=none,if=virtio -boot c -m 2G -smp 2 -numa node,nodeid=0 -numa node,nodeid=1 -localtime -usb -usbdevice tablet -cpu SandyBridge -net nic,macaddr=B4-B5-2F-AB-C4-CA,model=virtio -net user -balloon virtio -vga std -drive file=virtio-win-0.1.118.iso,index=0,media=cdrom
  7. Export the Internet Settings from the host machine and import them to the VM
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
  8. Configure WinHTTP proxy
    netsh.exe winhttp show proxy
    netsh.exe winhttp import proxy source=ie

    N.B. configure WinHTTP proxy 32 bits (C:\Windows\Syswow64\cmd.exe)

  9. Start using your new Windows Server on your desktop2016-10-05-16_42_34-qemu

Local Windows Variables

ws2012Context
You would like to bypass some Windows System Variable for the execution of an application. You could use a script and create some local values to be able to correctly launch the program without any error.

:: Update the PATH to Oracle Client X86

@ECHO OFF

SETLOCAL ENABLEEXTENSIONS
SET PATH=D:\SysApp\Oracle\Ora11g_x86\;D:\SysApp\Oracle\Ora11g_x86\bin;
SET ORACLE_HOME=

fim.RT.GN.Uss.CoronaInquiry.WinForms.exe

ENDLOCAL

Microsoft SQL with JDBC

javalogo-81x162

Context
You would like to connect to Microsoft SQL server with JDBC. You could use this tool “JdbcSQLServerConnection” version 3 and specify the required information to test.the connection.2016-08-17 15_57_24-be-s1213-ms3.adroot.local

/* 
Project : Move ICFT Database to AZI Zone Data D1
Function : Connect to Microsoft SQL Server via JDBC
Author : Stéphane Estival
Date Build : 17/08/2016
Version : 3
*/

package input;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.swing.*;

public class JdbcSQLServerConnection3 extends JPanel {
 
 static JFrame frame;
 private static final long serialVersionUID = 1L; // Not mandatory variable
 private JButton loginButton = new JButton("Test Connection"); // Test Connection Button
 final JTextField serverText = new JTextField(); // User input field 1
 final JTextField userText = new JTextField(); // User input field 2
 final JPasswordField passwordText = new JPasswordField(); // User input field 3
 final JTextField databaseText = new JTextField(); // User input field 4
 
 public JdbcSQLServerConnection3() {
 
 //BoxLayout
 setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
 
 //Create the listener for the button
 ClickListener cl = new ClickListener();
 
 //Create all text + input
 JLabel headerLabel = new JLabel("Specify the following to connect to SQL Server data:");
 JLabel blankLabel = new JLabel("\n");
 JLabel serverLabel = new JLabel("1. Enter a server name : port");
 JLabel blankLabel2 = new JLabel("\n");
 JLabel logonLabel = new JLabel("2. Enter information to log on to the server:");
 JLabel userLabel = new JLabel("User name:");
 JLabel passwordLabel = new JLabel("Password:");
 JLabel blankLabel3 = new JLabel("\n");
 JLabel databaseLabel = new JLabel("3. Specify the database:");
 JLabel blankLabel4 = new JLabel("\n");
 
 //Lay out everything
 JPanel patternPanel = new JPanel();
 patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
 patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
 setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
 
 //Lay out text + input
 patternPanel.add(headerLabel);
 patternPanel.add(blankLabel);
 patternPanel.add(serverLabel);
 patternPanel.add(serverText);
 patternPanel.add(blankLabel2);
 patternPanel.add(logonLabel);
 patternPanel.add(userLabel);
 patternPanel.add(userText);
 patternPanel.add(passwordLabel);
 patternPanel.add(passwordText);
 patternPanel.add(blankLabel3);
 patternPanel.add(databaseLabel);
 patternPanel.add(databaseText);
 patternPanel.add(blankLabel4);
 patternPanel.add(loginButton);
 
 loginButton.addActionListener(cl); // Add the listener to the test button
 add(patternPanel);
 add(Box.createRigidArea(new Dimension(0, 10)));
}

 private class ClickListener implements ActionListener { // Connect to the server on click
 public void actionPerformed(ActionEvent e) {
 try {
 checkJDBCLink();
 } catch (HeadlessException e1) {
 e1.printStackTrace();
 } catch (UnsupportedEncodingException e1) {
 e1.printStackTrace();
 }
 }

 private void checkJDBCLink() throws HeadlessException, UnsupportedEncodingException {
 
 Connection conn = null;
 
 //Redirect println output to dialog window
 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 System.setOut(new PrintStream(bos));
 
 //Define variables for user input fields
 String server = serverText.getText();
 String user = userText.getText();
 char[] password = passwordText.getPassword();
 String pwd = String.copyValueOf(password); // Converting from array to string
 String database = databaseText.getText();
 String dbURL = "jdbc:sqlserver://"+server+";databaseName="+database+";";
 
 // Check if all the fields are filled
 if ((server.length()!=0) && (user.length()!=0) && (pwd.length()!=0) && (database.length()!=0)) {
 
 // Start the JDBC connection
 try {
 
 conn = DriverManager.getConnection(dbURL, user, pwd);
 
 if (conn != null) {
 //Build text message information
 DatabaseMetaData dm = (DatabaseMetaData) conn.getMetaData();
 System.out.println("\nDriver name: " + dm.getDriverName());
 System.out.println("Driver version: " + dm.getDriverVersion());
 System.out.println("Product name: " + dm.getDatabaseProductName());
 System.out.println("Product version: " + dm.getDatabaseProductVersion());
 
 //Display the dialog information window
 JOptionPane.showMessageDialog(null, 
 "Test connection succeeded.\n" + bos.toString("UTF-8") + "\n",
 "Microsoft SQL Server via JDBC",
 JOptionPane.INFORMATION_MESSAGE); 
 }
 }
 
 catch (SQLException ex) {
 //Display the dialog error window
 JOptionPane.showMessageDialog(null, 
 "TCP/IP connection to "+server+" has failed.\nMake sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port.\nMake sure that TCP connections to the port are not blocked by a firewall." + bos.toString("UTF-8"),
 "Microsoft SQL Server via JDBC",
 JOptionPane.ERROR_MESSAGE);
 } 
 
 finally {
 try {
 if (conn != null && !conn.isClosed()) {
 conn.close();
 }
 } 
 catch (SQLException ex) {
 ex.printStackTrace();
 }
 }
 }
 else {
 //Display the dialog information window
 JOptionPane.showMessageDialog(null, 
 "Please complete all the required fields\n",
 "Microsoft SQL Server via JDBC",
 JOptionPane.INFORMATION_MESSAGE);
 }
 }
 }

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
 private static void createAndShowGUI() {
 
 //Create and set up the window
 JFrame frame = new JFrame();
 frame.setTitle("Microsoft SQL Server via JDBC");
 frame.setSize(375,460);
 frame.setResizable(false); 
 frame.setLocationRelativeTo(null); //Display the window to the center of the screen
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 //Create and set up the content pane
 JComponent newContentPane = new JdbcSQLServerConnection3();
 newContentPane.setOpaque(true); //Content panes must be opaque
 frame.setContentPane(newContentPane);

 //Display the window
 frame.pack();
 frame.setVisible(true);
 }

 public static void main(String[] args) {

 //Schedule a job for the event-dispatching thread:
 //creating and showing this application's GUI.
 javax.swing.SwingUtilities.invokeLater(new Runnable() {
 public void run() {
 createAndShowGUI();
 }
 });
 }
}

Test Microsoft SQL with JDBC

javalogo-81x162

Context
You would like to test a connection to Microsoft SQL Server via JDBC. You could create a Java application and use it on the required client.

1. Install Eclipse IDE
2. Create a New Java Project and Add the Microsoft JDBC Driver “sqljdbc4.jar”
3. Edit the source code “JdbcSQLServerConnection2.java” and Run As Java Application

/* 
Project : Move ICFT Database to AZI Zone Data D1
Function : Connect to Microsoft SQL Server via JDBC
Author : Stéphane Estival
Date Build : 12/08/2016
*/

package jdbc2;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.swing.JOptionPane;

public class JdbcSQLServerConnection2 {

 public static void main(String[] args) throws UnsupportedEncodingException {
 
 Connection conn = null;
 
 // Redirect println output to dialog window
 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 System.setOut(new PrintStream(bos));
 
 try {
 
 String dbURL = "jdbc:sqlserver://BE-S1460-MS3:1533;databaseName=IDXX_int";
 String user = "";
 String pass = "";
 conn = DriverManager.getConnection(dbURL, user, pass);
 
 if (conn != null) {
 // Build text message information
 System.out.println("\nServer name: BE-S1460-MS3:1533");
 System.out.println("Database name: IDXX_int");
 DatabaseMetaData dm = (DatabaseMetaData) conn.getMetaData();
 System.out.println("\nDriver name: " + dm.getDriverName());
 System.out.println("Driver version: " + dm.getDriverVersion());
 System.out.println("Product name: " + dm.getDatabaseProductName());
 System.out.println("Product version: " + dm.getDatabaseProductVersion());
 
 // Display the dialog information window
 JOptionPane.showMessageDialog(null, 
 "Test connection succeeded.\n" + bos.toString("UTF-8"),
 "Microsoft SQL Server via JDBC",
 JOptionPane.INFORMATION_MESSAGE); 
 }
 
 } catch (SQLException ex) {
 // Display the dialog error window
 JOptionPane.showMessageDialog(null, 
 "The TCP/IP connection to the host BE-S1460-MS3, port 1533 has failed.\nMake sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port.\nMake sure that TCP connections to the port are not blocked by a firewall." + bos.toString("UTF-8"),
 "Microsoft SQL Server via JDBC",
 JOptionPane.ERROR_MESSAGE);
 } finally {
 try {
 if (conn != null && !conn.isClosed()) {
 conn.close();
 }
 } catch (SQLException ex) {
 ex.printStackTrace();
 }
 }

 }
}

4. Export as Runnable JAR file
2016-08-11 13_18_13-be-s1219-xa3.adroot.local2016-08-11 13_18_25-be-s1219-xa3.adroot.local
5. Double click the JAR file to launch the test
2016-08-12 12_17_18-be-s1213-ms3.adroot.local2016-08-11 13_26_06-be-s1213-ms3.adroot.local

If the connection failed, it display this error message2016-08-12 12_42_22-Program Manager