Open Source Software and Linux:

gui

Sep 4 2008   11:54AM GMT

Script Word and OpenOffice documents to pdf



Posted by: John Little
Microsoft Windows, Linux, Lotus Domino, gui, scripting, script, centos, word, openoffice, putty, automate, autoit, microsoft work, Open Office, scp, pscp

I ran into a situation a couple of weeks ago where it would be convenient to script Word and OpenOffice documents into pdf format. One of my jobs here is to create the network and email login documentation for newly hired people. I have the document creation automated through an AutoIT script. I previously posted about AutoIT here.

The next step after creating the Word document is to copy it to my Linux workstation where my Lotus Notes client resides. Once there I want to convert it to pdf and attach it to an email for sending to the new hire’s manager.

I copy the newly created Word document using Putty’s pscp application. This script is called from the AutoIT script that creates the documents. The pscp script is written as follows:

pscp -pw mypassword -r c:\userdocs jslittl@centos5-xvm:/home/jslittl/Documents/Notes-Domino/users2convert

You can place this script at the end of your AutoIT script so that it copies your document to wherever you want. So this is where I am in the process: AutoIT script to create the document => scp the document to my Linux workstation.

I followed the instructions here to setup OpenOffice for scripting the documents to pdf. My script to do so is setup like this:

[jslittl@centos5-xvm userdocs]$ cat convertDir2PDF.sh
#!/bin/sh
for i in *.doc; do echo $i; doc2pdf “$i”; sleep 5; done #this will convert all documents in the directory
# zip newusers *.pdf # this is for when there are a large number documents going to the same place-easier to attach 1 zip file
mv *.doc `pwd`/finished-doc # I created the next 3 directories to hold the finished documents
mv *.pdf `pwd`/finished-pdf
mv *.zip `pwd`/finished
[jslittl@centos5-xvm userdocs]$

That’s it! Just attach them to the email and send them on.

Sep 1 2008   9:34PM GMT

Ubuntuserver is unbelievably stupid



Posted by: John Little
Linux, ssh, gui, centos, zimbra, grub, lilo, ubuntu, ubuntuserver, inittab, ubuntuserver upgrade, headless

Yes you read the title right. Ubunutserver is unbelievably stupid.

Ok let’s take it from the top. I had Ubuntuserver 7.0.4 installed as my WebDAV secure server, my son’s baseball team’s website, samba and so on. I run this server headless and without a gui. Note here that the normal install is without a gui and is touted loudly by the folks who develop ubuntuserver. This is all well and good.

Lately it’s been on my mind to look into and install a collaboration suite. Having searched around I finally landed on Zimbra.

After reading the documentation I see that Zimbra is certified on Ubuntu 8.04 LTS. Ok, well this is as good of a time to upgrade as any. This is where the fun (read stupidity) begins.

I ssh into my server as normal. I do all of the pre-distribution upgrade stuff, reboot and begin the distribution upgrade. The first thing I get is a message saying something to the effect of “We do not recommend using SSH while you upgrade. If you lose a connection it is difficult to recover.” Ok. I’m not doing this over a WAN link but on my local LAN. I haven’t had any network outages since I don’t know when, the sun is shining so no power outages looming. Things are looking good.

The upgrade proceeds smoothly. On several occasions I am asked if I want to replace any of my configuration files. This include the sshd configuration file. On all of these I take the default which is “Do not replace, I want to keep the configuration file that I am currently using” . That’s paraphrased but that is what it meant.

The distribution upgrade finishes. I get a nice message saying everything went well and asking me if I want to reboot. Of course I do. I type y and off we go. After waiting the appropriate amount of time I try to SSH back in. I am pretty excited at this point about getting my Zimbra install started.

Uhoh. No such luck. The dreaded “ssh: connect to host 10.10.15.105 port 22: Connection refused” message. What?!? Are you kidding me? No way. I try pinging the server. Yep, network came back ok. I try again. Nope. And several times after that. Now I’m writing this rant.

You see, here is why I think this is stupid. The server installs without a gui. That implies that no one is going to use this for a workstation. If no one is going to use it for a workstation, why then, should it have a monitor on it? If it doesn’t have a monitor on it, why would you not want someone to upgrade using SSH? Would the Ubuntuserver people prefer telnet instead? If the upgrade process is smart enough to know that you are upgrading over SSH then why not start SSHD on the reboot? If that is in fact the problem since I haven’t dragged a monitor over there to see.

I made a decision not long ago not to scrap my Ubuntuserver in favor of CentOS. I am starting to regret that decision. You see there is at least one other annoyance with Ubuntusever that I don’t find appealing either. This is the fact that they have decided that using an inittab is old fashioned or something. While this doesn’t have much affect on a server, at least one not running a gui, have you tried to boot into runlevel 3 lately? It’s not nearly as easy as it is with a GRUB boot loader where you can edit it, type in 3, hit enter and b and boot to runlevel 3.

Ok, I’m done. Next free time that I have I’m putting CentOS on there (as soon as I drag a monitor to the server and get SSHD started that is).

-j


Aug 29 2008   3:35PM GMT

Script repetitious tasks in a GUI with AutoIT



Posted by: John Little
windows, Microsoft Windows, Lotus Domino, gui, scripting, script, automate, autoit

Do you find yourself wanting to script repetitious tasks in a GUI? Wish there was a way to automate it? There is now.

Unlike shell scripting where many tasks can be automated this is generally more difficult in a GUI. You have mouse clicks and keyboard entries to make in a GUI. AutoIT is the answer to your problem. AutoIT is designed to script repetitious tasks in a GUI, specifically the Windows GUI and Windows applications.

AutoIT is freeware - not open source - designed to automate the Windows GUI and perform other general scripting tasks. I use it at work for setting up users in Active Directory and Lotus Notes. The Active Directory part I send to the Windows command line. The Notes part is done inside the Notes client. I even have it send the New User documentation over to my Linux workstation via SCP. There I have a Bash script convert the documents to PDF to be sent to HR. Pretty cool. It saves me hours of work every Friday. Which is why I can write this post and tell you about it :-)

The AutoIT download comes with a lite version of the SciTe IDE. You can download a full blown version customized to work with AutoIT here. With the IDE you get syntax highlighting, script tidying, debug, the ability to compile the script to an .exe file and more. AutoIT even integrates into the right click text menu so that right clicking on the script gives you the ability to run, compile or edit the script. autoit-editor

If you need to send your scripts out to users, for instance to have them perform some task or installation on their machine, the compile function is a real life saver. We use it to compile the script that installs and sets up the VPN and then send it to remote users. Just burn it to a CD along with the necessary files so that it will autorun and Voila!..no more trying to do it over the phone. Or you could just send all of the files zipped up in an email and have them put it in a folder for running..but that does require relying on the user to do something.

AutoIT also provides AU3Info. AU3Info is a tool that will help you find window titles, mouse coordinates and much more window information that will help in writing your script. You need the active window titles and mouse coordinates so that AutoIT knows when a certain window is active. Once the window is active you tell the script where to place the mouse, left or right click if necessary and what keystrokes to send.
au3spy

AutoIT comes with a full complement of everything required to write any sort of script whether you need to manipulate a GUI or something that you need to run from the command line. These include datatypes, functions, macros and many others.

The documentation is excellent and very easy to understand. The forums are active and friendly to new users. So if you’re tired of doing that repetitious Windows task why not give AutoIT a spin! It’s a great tool for any administrator.

Full disclosure: I am in no way associated with AutoIT other than being a satisfied user.