variable value not storing inside file
I wrote following script, which generate random password and store it in file
pass1=</dev/urandom tr -dc _A-Z-a-z-0-9|head -c8
echo $pass1
echo "$pass1" >/tmp/a
Above script printing generated password through “echo $pass1″ command. But nothing getting stored inside created /tmp/a file .
Please let me know whats wrong i am doing.
It’s not necessary to store the password in an intermediate variable. You only need this line in your shell script
</dev/urandom tr -dc _A-Z-a-z-0-9|head -c8 > /tmp/a
I saved as foo.sh, made permissions 755, and executed it under linux…
[mpenning@chestnut ~]$ uname -a
Linux chestnut.he.net 2.6.32.46-1-grsec #1 SMP Fri Sep 2 12:42:23 PDT 2011 x86_64 GNU/Linux
[mpenning@chestnut ~]$ ./foo.sh
[mpenning@chestnut ~]$ cat /tmp/a
qAUezN0-[mpenning@chestnut ~]$
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
- Windows File Permissions and Attributes
- What is the easiest way to upgrade my existing Perl 5.14 to Perl 5.16 on FreeBSD 9 using the ports system?
- Know if mysql has done its job
- Redirect https .com to https .co.uk without a valid SSL cert on .com without DNS change
- Why is it a bad idea to use customer email as from address
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





