Print a decimal number
$ printf "%d\n" 5
5
Print as float (default 6 decimal places)
$ printf "%f\n" 5
5.000000
Convert a hex number to decimal
$ printf "%d\n " 0xF
15
Convert a decimal number to Hex
$ printf "0x%X\n " 15
0xF
Convert a decimal number to Octal
$ printf "0%o\n " 8
010
7.15.2004
7.13.2004
Solaris: Truss basics
The truss command traces library and system calls and signal activity for a given process. This can be very useful in locating problems with a particular process. To run the command you must be root and know the process Id of the command you wish to trace:
truss -p PID
You'll end up getting some output in the following format:
F15K >truss -p 4660
*** SUID: ruid/euid/suid = 200 / 0 / 0 ***
*** SGID: rgid/egid/sgid = 200 / 100 / 100 ***
semop(262145, 0x006C74E8, 1) (sleeping...)
Received signal #14, SIGALRM, in semop() [caught]
semop(262145, 0x006C74E8, 1) Err#4 EINTR
kill(4658, SIG#0) = 0
times(0x006C6FB0) = 55227913
alarm(3) = 0
setcontext(0x006C7140)
semop(262145, 0x006C74E8, 1) (sleeping...)
Your command output will vary, but you can see some of following items in a truss output:
brk() requests memory during execution.
exec() opens a program.
fcntl() performs control functions on open files.
fstat() obtains information about open files.
getdents64() reads directory information.
ioctl() performs terminal I/O.
lstat() obtains file attributes.
mmap() maps the program image into memory.
open() opens a file. It returns a number which is referenced when the file is used.
write() writes to an open file/device.
Obviously, this is only a subset of the system calls seen in truss output, but this subset is usually sufficient to figure out what is going on. Other system calls can be looked up in the Sun web pages or man pages. In most cases we will be looking for error messages in the truss output. These entries will contain the string "Err" in the last column of the output.
These errors can be categorized as system call errors or missing file errors. Many missing file errors are the result of a library not being in a directory early in the LD_LIBRARY_PATH or something of the sort. If the truss output shows a successful open() (or whatever) of the file name later in the process, that is probably not your culprit.
System call errors can be interpreted by looking at the man page of the specific system call or examining the file /usr/include/sys/errno.h.
truss -p PID
You'll end up getting some output in the following format:
F15K >truss -p 4660
*** SUID: ruid/euid/suid = 200 / 0 / 0 ***
*** SGID: rgid/egid/sgid = 200 / 100 / 100 ***
semop(262145, 0x006C74E8, 1) (sleeping...)
Received signal #14, SIGALRM, in semop() [caught]
semop(262145, 0x006C74E8, 1) Err#4 EINTR
kill(4658, SIG#0) = 0
times(0x006C6FB0) = 55227913
alarm(3) = 0
setcontext(0x006C7140)
semop(262145, 0x006C74E8, 1) (sleeping...)
Your command output will vary, but you can see some of following items in a truss output:
brk() requests memory during execution.
exec() opens a program.
fcntl() performs control functions on open files.
fstat() obtains information about open files.
getdents64() reads directory information.
ioctl() performs terminal I/O.
lstat() obtains file attributes.
mmap() maps the program image into memory.
open() opens a file. It returns a number which is referenced when the file is used.
write() writes to an open file/device.
Obviously, this is only a subset of the system calls seen in truss output, but this subset is usually sufficient to figure out what is going on. Other system calls can be looked up in the Sun web pages or man pages. In most cases we will be looking for error messages in the truss output. These entries will contain the string "Err" in the last column of the output.
These errors can be categorized as system call errors or missing file errors. Many missing file errors are the result of a library not being in a directory early in the LD_LIBRARY_PATH or something of the sort. If the truss output shows a successful open() (or whatever) of the file name later in the process, that is probably not your culprit.
System call errors can be interpreted by looking at the man page of the specific system call or examining the file /usr/include/sys/errno.h.
UNIX: Streaming Tar
1. Move the files
2. Verify everything got moved
If everything looks good and the sizes match on the du files you are golden
cd src_dir
tar cf - . | (cd dest_dir; tar xvf - )
2. Verify everything got moved
cd src_dir
du -ak . > /tmp/src_dir.info
du -ak . > /tmp/dest_dir.info
diff /tmp/src_dir.info /tmp/dest_dir.info
If everything looks good and the sizes match on the du files you are golden