User Tools

Site Tools


script_to_parse_space_separated_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

script_to_parse_space_separated_file [2009/07/08 02:59]
k2patel
script_to_parse_space_separated_file [2020/08/10 02:35]
Line 1: Line 1:
-====== Parsing file for actions ====== 
  
-This script i have created to create qmail user using space separated file.\\ 
-File format i have received is <​user>​ <account / forward> <​forward>​ <​forward>​ <​forward>​ <​forward>​ <​forward>​ <​forward>​ \\ 
-but the forwarder was not fixed. 
- 
-<code bash | generate.sh>​ 
-#​!/​usr/​local/​bin/​bash ​                                                             ​ 
-while read inputline ​                                                               
-do                                                                                  
-maine="​$(echo $inputline | awk '​{print $1}'​)" ​                                     ​ 
-typee="​$(echo $inputline | awk '​{print $2}'​)" ​                                     ​ 
-fwrd1="​$(echo $inputline | awk '​{print $3}'​)" ​                                     ​ 
-fwrd2="​$(echo $inputline | awk '​{print $4}'​)" ​                                     ​ 
-fwrd3="​$(echo $inputline | awk '​{print $5}'​)" ​                                     ​ 
-fwrd4="​$(echo $inputline | awk '​{print $6}'​)" ​                                     ​ 
-fwrd5="​$(echo $inputline | awk '​{print $7}'​)" ​                                     ​ 
-fwrd6="​$(echo $inputline | awk '​{print $8}'​)" ​                                     ​ 
-usernm="​$(echo $maine | awk -F @ '​{print $1}'​)"​ 
- 
-if [ "​$typee"​ == "​A"​ ]; then 
-        /​usr/​local/​bin/​vadduser $maine <​password> ​  # replace <​password>​ with your password 
-        file=$usernm/​.qmail 
-        echo "​$file"​ 
-else 
-        file="​.qmail-$usernm"​ 
-        echo "​$file"​ 
-fi 
-if [ "​$fwrd1"​ != ""​ ];then 
-        echo "&​$fwrd1"​ >> $file 
-fi 
-if [ "​$fwrd2"​ != ""​ ];then 
-        echo "&​$fwrd2"​ >> $file 
-fi 
-if [ "​$fwrd3"​ != ""​ ];then 
-        echo "&​$fwrd3"​ >> $file 
-fi 
-if [ "​$fwrd4"​ != ""​ ];then 
-        echo "&​$fwrd4"​ >> $file 
-fi 
-if [ "​$fwrd5"​ != ""​ ];then 
-        echo "&​$fwrd5"​ >> $file 
-fi 
-if [ "​$fwrd6"​ != ""​ ];then 
-        echo "&​$fwrd6"​ >> $file 
-fi 
-done 
-</​code>​ 
- 
- 
-Following is script does not work. \\ 
-but will fix it shortly.\\ 
- 
-**Use with your own risk** 
- 
-<code bash | generate1.sh>​ 
-#​!/​usr/​local/​bin/​bash 
-while read inputline 
-do 
-maine="​$(echo $inputline | awk '​{print $1}'​)"​ 
-typee="​$(echo $inputline | awk '​{print $2}'​)"​ 
-fwrd1="​$(echo $inputline | awk '​{print $3}'​)"​ 
-fwrd2="​$(echo $inputline | awk '​{print $4}'​)"​ 
-fwrd3="​$(echo $inputline | awk '​{print $5}'​)"​ 
-fwrd4="​$(echo $inputline | awk '​{print $6}'​)"​ 
-fwrd5="​$(echo $inputline | awk '​{print $7}'​)"​ 
-fwrd6="​$(echo $inputline | awk '​{print $8}'​)"​ 
-usernm="​$(echo $maine | awk -F @ '​{print $1}'​)"​ 
- 
-if [ "​$typee"​ == "​A"​ ]; then 
-        /​usr/​local/​bin/​vadduser $maine <​password> ​  # replace <​password>​ with your password 
-        file=$usernm/​.qmail 
-        echo "​$file"​ 
-else 
-        file="​.qmail-$usernm"​ 
-        echo "​$file"​ 
-fi 
- 
-for i in 1 2 3 4 5 6 
-        do 
-                if [ "​$fwrd$i"​ != ""​ ];then 
-                        echo "&​$fwrd$i"​ >> $file 
-                fi 
-        done 
-done 
-</​code>​ 
script_to_parse_space_separated_file.txt ยท Last modified: 2020/08/10 02:35 (external edit)