≡ Menu

Temporary memory files and shell scripts

Recently we got lots of discussion about shell scripts that create a temporary memory files and only available to the invoked shell but not visible to any other user or process except root user. If we use /tmp directory to create file then it will be available to everyone. Next comes the idea of here document feature. For example following simple shell program uses here document feature

cat << STOP
echo $DATA1

However soon we discovered that here documents is implemented as temporary file by bash shell. For example if we run strace on script we can easily see it is opening file in /tmp
$ strace -f script.bash

Bottom line if data is such critical scripts are useless, it is better go with private directory or write program in C.

Share this on:

{ 0 comments… add one }

Leave a Comment