Sponsored Content
Top Forums Shell Programming and Scripting Encyrpt does not work in bash script Post 303002850 by yash_message on Sunday 3rd of September 2017 12:21:16 PM
Old 09-03-2017
Jim, Thanks for your reply.

I have changed in the script, what you suggested. but in shadow file does not put password correctly. it left after dollar($) sign.
It works fine in command prompt.

Please find my script and running output.

Code:
[root@server-rhel6 ~]# cat adduser.sh
#!/bin/bash
for i in `cat servername1`;
do
ssh -q -t root@$i sudo /usr/sbin/useradd -u 1001 -s /bin/bash -m -d /home/testuser -c 'URid_testuser-p "\$6\$h8GQyPz4\$I1C.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St." testuser
echo testuser created on server $i
done

Running script with -x option-----

Code:
[root@server-rhel6 ~]# sh -x adduser.sh
++ cat servername1
+ for i in '`cat servername1`'
+ ssh -q -t root@node1-rhel6 sudo /usr/sbin/useradd -u 1001-p '$6$h8GQyPz4$I1C.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St.' testuser
+ echo testuser created on server node1-rhel6
testuser created on server node1-rhel6
+ for i in '`cat servername1`'
+ ssh -q -t root@node2-rhel6 sudo /usr/sbin/useradd -u 1001 -s /bin/bash -m -d /home/adubey01 -c URid_testuser -p '$6$h8GQyPz4$I1C.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St.' testuser
+ echo testuser created on server node2-rhel6
testuser created on server node2-rhel6
[root@server-rhel6 ~]#

Shadow file output-----

Code:
testuser:.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St.:17410:0:99999:7:::

Please suggest.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 09-03-2017 at 01:31 PM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

2. Shell Programming and Scripting

Open and work on a .doc file with bash script

Hello there....unix users :) I hope you can help me with this: I need open a doc file or xls files and work this files whit a bash script. For example: Open a doc file and copy information from a txt file in this doc file or xls file. Is it possible? Sorry for my english...I'm chilean... (3 Replies)
Discussion started by: bobbasystem
3 Replies

3. Shell Programming and Scripting

cant get a counter to work in bash scipt, this is calling expect script

I have looked high and low, tryed lots of diffrent things but cant get a simple counter to work right. what i need is to increase a count ever time it finishes the test, pass or fail. example TEST PASS 1, NEXT TEST PASS 2, I curently have set foo o while {$foo <=5} { incr foo puts... (1 Reply)
Discussion started by: melvin
1 Replies

4. Shell Programming and Scripting

pipe to grep doesn't work in bash script

Hi, I'm trying to write a script that checks gvfs to see if a mount exists so I can run it from network-manager's status hooks. I thought I'd pipe the output of gvfs-mount -l to grep for the particular mounts I care about. When I do this in a bash script: cmnd="gvfs-mount -l | grep -i... (4 Replies)
Discussion started by: kcstrom
4 Replies

5. Shell Programming and Scripting

My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os. my script. logFiles="sentLog1.log sentLog2.log" intial_time="0 0" logLocation="/usr/local/tomcat/logs/" sleepTime=600 failMessage=":: $(tput bold)Log not update$(tput rmso) = " successMessage="OK" arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies

6. Shell Programming and Scripting

Nested double quotes won't work in my bash script?

In a bash script I have: LSCMD="find /project/media/ -mindepth 2 -maxdepth 2 -name \"files*pkg\"" ALL_PACKAGES=$( $LSCMD | sort 2>/dev/null) But I get nothing returned. It's just all blank. If I run the find command in a terminal, I get dozens of hits. I figure it's the way how I'm... (3 Replies)
Discussion started by: superbbrr
3 Replies

7. Shell Programming and Scripting

Rsync in bash script doesn't work even after placing pub key in target server

Hello Friends, My bash script is like this #!/bin/bash # request Bourne shell as shell for job #$ -S /bin/bash # assume current working directory as paths #$ -cwd #$ -N rsync-copy # # print date and time date rsync -rltD --progress "ssh -i /home/myname/.ssh/id_rsa"... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

8. Shell Programming and Scripting

Bash script: "mkdir -p" doesn't work with var(cat x)

Hello, :) I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output : #!/bin/bash # PATHS HOME_BACKUP="/home/backup" HOME_SCRIPT="/home/scripts/test/backup_server" TARGET="/var/www" # DATE DATE_Ymd=$(date +%Y-%m-%d) #... (1 Reply)
Discussion started by: Arnaudh78
1 Replies

9. AIX

Bash does not work on AIX 7.2

We have a new LPAR with AIX 7.2. We want to work with bash, so installed bash from Perzl (bash_64-4.4.5.aix5.1.ppc.rpm). But after install bash does not work. If I call "bash", nothing happens. The xterm, where I started bash, is totally dead. I tried the bash from aixtools.net, too. Same... (4 Replies)
Discussion started by: BuSchu
4 Replies

10. UNIX for Beginners Questions & Answers

Bash script does not work as expected

Repeat this text in a file named notes.txt and run the script Before bash is a good language a blank line appears Also, the following notes are displayed incorrectly What is bad? ================================== Title : Note 1 ================================== Category: Computer Date... (3 Replies)
Discussion started by: cesar60
3 Replies
GZEXE(1)						      General Commands Manual							  GZEXE(1)

NAME
gzexe - compress executable files in place SYNOPSIS
gzexe [ name ... ] DESCRIPTION
The gzexe utility allows you to compress executables in place and have them automatically uncompress and execute when you run them (at a penalty in performance). For example if you execute ``gzexe /bin/cat'' it will create the following two files: -r-xr-xr-x 1 root bin 9644 Feb 11 11:16 /bin/cat -r-xr-xr-x 1 bin bin 24576 Nov 23 13:21 /bin/cat~ /bin/cat~ is the original file and /bin/cat is the self-uncompressing executable file. You can remove /bin/cat~ once you are sure that /bin/cat works properly. This utility is most useful on systems with very small disks. OPTIONS
-d Decompress the given executables instead of compressing them. SEE ALSO
gzip(1), gznew(1), gzmore(1), gzcmp(1), gzforce(1) CAVEATS
The compressed executable is a shell script. This may create some security holes. In particular, the compressed executable relies on the PATH environment variable to find gzip and some other utilities (tail, chmod, ln, sleep). BUGS
gzexe attempts to retain the original file attributes on the compressed executable, but you may have to fix them manually in some cases, using chmod or chown. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgzip | +--------------------+-----------------+ |Interface Stability | External | +--------------------+-----------------+ NOTES
Source for gzip is available in the SUNWgzipS package. GZEXE(1)
All times are GMT -4. The time now is 04:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy