Archive for the 'unix' Category
Problem You want to get up and running with sqlite Solution Install sqlite3 on linux, via yum: yum install sqlite3Then just run sqlite dbname Example % sqlite3 testdata.dbSQLite version 3.5.9Enter “.help” for instructionssqlite> create table memos(text,priority INTEGER);sqlite> insert into memos values(‘deliver project description’,10);sqlite> insert into memos values(‘lunch with Christine’,100);sqlite> select * from memos;deliver project description|10lunch [...]
September 1st, 2009 | Posted in unix-coding-training | No Comments
Problem Getting an error about not being able to find libraries (file not found), when starting up a binary – such as httpd. Solution You need to identify the shared libraries required by your binary. Ordinarly we use the ldd command for this and amended LD_LIBRARY_PATH to find the libs – see example below.You might [...]
August 27th, 2009 | Posted in unix-coding-specialist | No Comments
Problem Different versions of UNIX handle the stripping of newlines in a string differently. Obviously if you echo a string, the shell automatically expands newlines “\n”. Solution sed and tr don’t appear to like performing these substitutions. But with Perl its a steal. Example % echo ‘hello world\nhello world\ntest it’ | perl -ane ‘s#\\n# #g; [...]
June 1st, 2009 | Posted in unix-coding-training | No Comments
Problem You want to resize images from the command line. Solution Use image magik mogrify command.mogrify -resize “percentage” image_naAlso you can view current sizing – like this:% identify IMG_3864.JPGIMG_3864.JPG JPEG 563×422 563×422+0+0 DirectClass 8-bit 32.8887kb Example mogrify -resize 20% IMG_3705.JPG Reference Technorati Tags: mogrifymogrify man page – resize an image
May 18th, 2009 | Posted in unix-coding-training | No Comments
Problem You want to listen on a pipe and perform commands, based on the text sent to the pipe.This could be useful for triggering action based on events;Running code as different users – i.e. allow root or a functional user to run something – just need to allow access to group of users, via permission [...]
May 6th, 2009 | Posted in unix-coding-specialist | No Comments
Problem You want to get notified when a file arrives. Maybe it is coming in from somewhere else, or just is the result of some processing.What ever the case, never sit there waiting for a file to arrive again! Solution Put the code under example tab, in a cron entry. See reference for more detail [...]
January 22nd, 2008 | Posted in unix-coding-training | 1 Comment
Problem You want to debug a running process on Solaris?You want to debug running process on Linux? Solution See the example for debugging processes on Solaris or Linux – the syntax shows all system executes and reads. Example truss -xall -vall -rall -t’read’ -p PID #To run a command and have it produce debug info, [...]
January 1st, 2008 | Posted in unix-coding-specialist | No Comments
Problem You want to trace program execution on Solaris?You want to perform network tracing on Solaris?Perform a text dump of a binary file – or see ascii codes, etc?Generate some random data?List directory contents in 3 columns?Loop through a list of files and perform actions on them?Check for values in vars?Detach a process without it [...]
January 1st, 2008 | Posted in unix-coding-specialist | No Comments
Problem You want to find a pattern in a file and have the line displayed. Solution I “discovered” this undocument (well in all the doco I’ve ever read), pretty much by accident.Basically find produces a list of files (type f), in the current directory and supplies them individually to the grep command. Ordinarily if grep [...]
December 31st, 2007 | Posted in unix-coding-specialist | No Comments
Problem Ever need to look at a file, but have not been able to – due to hidden control characters, etc. Solution Or just needed to see spaces and end of line characters, comparing files, etc. Optical dump or more specifically the od command, can be extremely useful for display ascii characters. See the example. [...]
December 29th, 2007 | Posted in unix-coding-specialist | No Comments