Wednesday, August 9, 2017

/bin/rm: Argument list too long error

Today I found the following error returned by linux

[root@server1 cur]# rm *
-bash: /bin/rm: Argument list too long

After quick searching around I found how to remove files in case if there are too many files in the current directory:

find . | xargs rm

That allowed me to delete all files in that dir.

Thursday, April 7, 2016

How to grab collection list from IBM Watson Explorer

There is an easy way to get the list of collections from IBM Watson Explorer

OUT=$(curl -s "http://$HOST:$PORT/vivisimo/cgi-bin/velocity?v.username=$USER&v.password=$PWD&v.function=search-collection-list-xml&v.indent=true&v.app=api-rest")

echo $OUT > out2
COLLIST=$(xmllint --xpath "//vse-collection[starts-with(@name,'mycollection')]/@name" out2 | sed 's/name="//g' | sed 's/"//g')

COLLIST will return all collections which start with "mycollection"
You can further work on the list by using the following as an example:

for col in $COLLIST; do
getStatusFunction $col $PORT
done


Tuesday, October 27, 2015

How to make picture via face camera on macos?

If you would like to make a picture on your macbook, you can use face camera. It is quite easy - you just need to start "photo booth" software and make a picture. It will be saved in "Pictures" folder, so you can download them from there and use them as you would like.

Thursday, October 15, 2015

How to execute fixup or compact on macos?

How do you execute a local Fixup or Compact on Mac OS X running an IBM Notes client? Because there is no ncompact or nfixup executable on Apple Mac OS X, you will have to do it a bit different.

I do not use it often, but I always have to search for it...
- Open a Terminal Window
- Switch to the Notes App Directory:
  cd /Applications/IBM\ Notes.app/Contents/MacOS
- Set the environment variable DYLD_LIBRARY_PATH:   
  export DYLD_LIBRARY_PATH="/Applications/IBM Notes.app/Contents/MacOS"
- Switch to the Support subfolder:
  cd Support
- Execute NotesFixup or NotesCompact:
  ./NotesCompact
  ./NotesFixup

(without options you will do a compact for all databases in your Lotus Notes Data directory
/Users/YourUsername/Library/Application Support/Lotus Notes Data/ )
  ./NotesCompact mail/your-replica.nsf -c

(or with options for a special database)

Friday, October 2, 2015

db2 xml update command

Recently I needed to update db2 column based on XML extract from another field. By surprise, this is not documented very well. Here is how you can do it using SQL statement - make sure your db2 level is 9+:

       
update ibmcom.docstore set language = XMLCAST ( XMLQUERY('$c/externalMetaData/field[@name="Language"]/text()' passing EXTERNAL_METADATA as "c") AS VARCHAR(5))
       
 



Note that this script extracts XML node from XML field, which in my case looks similar to this:
<externalMetaData><field name="ContentType">text/html</field><field name="docid">http://www.blablabla.com/support?uid=2414412</field><field name="documentSource">pushAPI</field><field name="Language">en</field><field name="keywords">websphere</field><field name="Charset">UTF-8</field><field name="scopes">my</field></externalMetaData>

The language field is then extracted from XML and stored in appropriate column. The real trick is in the XMLCAST function, as if you do not use it, the UPDATE statement will fail.

Saturday, June 27, 2015

How to replace substring in linux

There is an easy way to do a mass replace of substring in linux. You can use perl command and a combination of "find/xargs/perl" like this:

find -name '*.log' -type f -print0 | xargs --null perl -pi -e 's/redhat/SUSE/'

The you can tweak the first part of the command (find) to point it to the files which have to be changed. redhat will be replaced with SUSE for all log files in this case.

Wednesday, April 22, 2015

How to set a password from command line in linux bash?

If you need to set a password from a command line automatically, you can use the following script:

echo myPassword | passwd myUser --stdin

This will ensure your password is send via pipe into passwd and set appropriately. It can be useful when you need to assign same password on different servers, so you can run this command remotely, over ssh.