"TIP: Script para convertir Doc a RFT"

He tenido que convertir todos los documentos doc que tenia en una carpeta a formato RTF (para que calibre me dejara pasarlos a distintos formatos).

Como eran unos pocos, en lugar de hacerlo a mano, he usado un script en VBS para ahorrarme un rato.

On Error Resume Next
Dim fso, folder, files, NewsFile,sFolder

Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = Wscript.Arguments.Item(0)
If sFolder = "" Then
Wscript.Echo "No Folder parameter was passed"
Wscript.Quit
End If
Set NewFile = fso.CreateTextFile(sFolder&"\FileList.txt", True)
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files

For each folderIdx In files
'NewFile.WriteLine(folderIdx.Name)
Doc2RTF folderIdx.Name 
Next
NewFile.Close


Sub Doc2RTF( myFile )
' This subroutine opens a Word document, then saves it as RTF, and closes Word.
' If the RTF file exists, it is overwritten.
' If Word was already active, the subroutine will leave the other document(s)
' alone and close only its "own" document.
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com

' Standard housekeeping
Dim objDoc, objFile, objFSO, objWord, strFile, strRTF

Const wdFormatDocument = 0
Const wdFormatDocument97 = 0
Const wdFormatDocumentDefault = 16
Const wdFormatDOSText = 4
Const wdFormatDOSTextLineBreaks = 5
Const wdFormatEncodedText = 7
Const wdFormatFilteredHTML = 10
Const wdFormatFlatXML = 19
Const wdFormatFlatXMLMacroEnabled = 20
Const wdFormatFlatXMLTemplate = 21
Const wdFormatFlatXMLTemplateMacroEnabled = 22
Const wdFormatHTML = 8
Const wdFormatPDF = 17
Const wdFormatRTF = 6
Const wdFormatTemplate = 1
Const wdFormatTemplate97 = 1
Const wdFormatText = 2
Const wdFormatTextLineBreaks = 3
Const wdFormatUnicodeText = 7
Const wdFormatWebArchive = 9
Const wdFormatXML = 11
Const wdFormatXMLDocument = 12
Const wdFormatXMLDocumentMacroEnabled = 13
Const wdFormatXMLTemplate = 14
Const wdFormatXMLTemplateMacroEnabled = 15
Const wdFormatXPS = 18

' Create a File System object
Set objFSO = CreateObject( "Scripting.FileSystemObject" )

' Create a Word object
Set objWord = CreateObject( "Word.Application" )

With objWord
' True: make Word visible; False: invisible
.Visible = True

' Check if the Word document exists
If objFSO.FileExists( myFile ) Then
Set objFile = objFSO.GetFile( myFile )
strFile = objFile.Path
Else
WScript.Echo "FILE OPEN ERROR: The file does not exist" & vbCrLf
' Close Word
.Quit
Exit Sub
End If

' Build the fully qualified HTML file name
strRTF = objFSO.BuildPath( objFile.ParentFolder, _
objFSO.GetBaseName( objFile ) & ".rtf" )

' Open the Word document
.Documents.Open strFile

' Make the opened file the active document
Set objDoc = .ActiveDocument

' Save as HTML
objDoc.SaveAs strRTF, wdFormatRTF

' Close the active document
objDoc.Close

' Close Word
.Quit
End With
End Sub

Colocad el script en el directorio donde esten los ficheros.doc, y desde la consola de DOS ejecutad:

doc2rtf.vbs .

Saludos

"TIP: Script para creacion de usuarios en Linux"

In case you need to define a lot of users in a Unix/Linux box, this small script could save you some time:

{% codeblock create_bulk_user.sh %} !/bin/bash file=.user_list.txt. for i in cat $file do user=echo $i | cut -d.;. -f1 pass=echo $i | cut -d.;. -f2 echo .Creating user: $user. useradd -m $user && echo .DONE. || echo .FAIL. echo .Creating entry in login.allow for user: $user. echo .$user all. >> /etc/login.allow echo .Setting the password for user: $user. echo .$pass. | passwd .stdin .$user. && echo .DONE. || echo .FAIL. echo .$user DONE. echo done

You just need to create the "user_list.txt" file containing your list of users/passwords in this format:

{% codeblock %} usuario1;pass1 usuario2;pass2

The script will create the user, set the password, and create an entry in allow.login

Bye!

TIPS: Instalar VMWARE en OpenSuse 11

Para instalar alguna de las diferentes versiones de VMWARE (ya sea Player, Workstation, o Server) es probable que una vez instalada la aplicaciós pida unas ciertas dependencias para compilar los móos:

{% img center http://2.bp.blogspot.com/_2-x1cSWxK2M/TR5rKIgQq0I/AAAAAAAAL7M/AxDGVOaXijc/s1600/vmware_req.png 320 320 %}

En OpenSuse es tan facil ejecutar desde un terminal:

zypper in gcc kernel-source kernel-syms

Saludos