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
#!/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.
You may also be interested in other helpful articles:
- Shell scripting (BASH) : How to create temporary random file name
- Security: Shell script optimization and security tips
- What is /dev/shm and its practical usage
- How to: Run All Shell / Perl / Python Scripts in a Directory
- Linux and UNIX Backing up key information or files
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


Recent Comments
Today ~ 15 Comments
Today ~ 51 Comments
Today ~ 4 Comments
Today ~ 14 Comments
Today ~ 8 Comments