(bash) echo "#!/bin/bash" event not found - trying to generate profiles automatically
Hi all,
I'm trying to write a simple bash script to create users on Linux and Solaris systems. Part of the spec is that I have to be able to generate a bash profile on the Solaris systems (this is done automatically on our Linux distros), so I wrote some code a bit like this: Code:
echo "#!/bin/bash" >> $USER_HOME.bash_profile Code:
bash: !/bin/bash": event not found Code:
$ echo "#\!/bin/bash" |
Hi,
Use single quotes instead of double quotes. I.e: echo '#!/bin/bash' >> $USER_HOME.bash_profile Or even better: Use an editor to make the script :) Hope this helps. |
Yeah, I don't know what this is. Maybe it has to do with accessing the history commands. Look at this:
Code:
skalkoto@darkstar:~$ echo "#!" Either put a space between ! and /. With this: Code:
#! /bin/bash Or even better use ' instead of ": Code:
skalkoto@darkstar:~$ echo '#!/bin/bash' |
Quote:
|
Quote:
Just to add some more information: Create a template file, e.g. bash_profile.template and simple copy it to the home directory, changing the name in the copy command. If you will use the useradd command, the "-m -k" options will create the home dir and copy the files from a template dir to the user's home dir. |
Hi all,
I type fast, give good advice and had an excelent yearly review at work today...... Guess I'm having a good day ;) |
Quote:
Don't forget to try the Lotto ! ;) |
*slaps forehead* I could have sworn I'd tried that and failed with the same result :( Oh well. Need more coffee I suppose.
BTW I thought of that idea of copying the profile, but you can't guarantee that the template is going to be in any specific location, especially when you're working cross platform. I had considered scp'ing it from somewhere, but this is just supposed to be a simple script and I don't want to mess around with keys or passwords. |
Hi,
Why not use /etc/skel to store the file. Both linux and slorais (9 at least) support this. If the content of /etc/skel isn't put in the (new) homedir automatically during user creation you could try to force it with useradd's -k skeleton_dir option. Hope this clears things up. |
This is more just a way to configure a user on any server, until we get some kind of centralised authentication mechanism going. I don't really want to have to put a default profile on every server on the network just yet.
|
All times are GMT -5. The time now is 01:48 AM. |