Temporary memory files and shell scripts

by on November 28, 2005 · 0 comments· LAST UPDATED November 28, 2005

in

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

#!/bin/bash
cat << STOP
DATA1=""
DATA2=""
echo $DATA1
STOP

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.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: