How to provide password for rsync in shell script?


Login or Register to Reply

 
Thread Tools Search this Thread
# 8  
Old 03-26-2015
Need help in shell scripting..Urgent ...Thanks in advance

I am very new to Unix shell scripting ..got some task on unix shell script..
Can you please help me in understanding the below part of shell script
Code:
PROCNAME=`basename $0 | awk -F"." '{print $1}'` 
export LOG_DT=`date '+20%y%m%d'`;
export LOG_TM=`date +'%H%M'`.log; 
export FCTN_LIB=${ARCH_BIN_DIR}/function_library.sh
. ${FCTN_LIB}
export LOG=${LOG_DIR}/${PROCNAME}.${LOG_DT}${LOG_TM}
export PFILE=${PROCNAME}.ksh_param
PGM=${PROCNAME}
clear
trap 'errhandle_se_je 1' 1 2 3 15

A=${1:-0}
B=${2:-0}  
C=${3:-0}  
D=${4:-30}
E=${5:-270}
F="$CDD/${PROCNAME}_dups.bad


Last edited by rbatte1; 04-07-2015 at 06:03 AM.. Reason: Added CODE tags
# 9  
Old 04-07-2015
Code:
PROCNAME=`basename $0 | awk -F"." '{print $1}'` 
export LOG_DT=`date '+20%y%m%d'`;
export LOG_TM=`date +'%H%M'`.log; 
export FCTN_LIB=${ARCH_BIN_DIR}/function_library.sh
. ${FCTN_LIB}
export LOG=${LOG_DIR}/${PROCNAME}.${LOG_DT}${LOG_TM}
export PFILE=${PROCNAME}.ksh_param
PGM=${PROCNAME}
clear
trap 'errhandle_se_je 1' 1 2 3 15

A=${1:-0}
B=${2:-0}  
C=${3:-0}  
D=${4:-30}
E=${5:-270}
F="$CDD/${PROCNAME}_dups.bad

Which part are you after explaining? There are seven distinct types of statement here. Which ones are confusing you. I don't want to confuse you.

I'm sure we can break it down for you.



Robin
# 10  
Old 04-07-2015
Code:
PROCNAME=`basename $0 | awk -F"." '{print $1}'`

Fills the variable PROCNAME with the basename (without path if existed), uses a dot as field seperator, and used the first part of the filename which was limited by dot/s.

Code:
export LOG_DT=`date '+20%y%m%d'`;

Fills and exports the variabe LOG_DT with the value of date, though should have used %Y rather than 20%y

Code:
export LOG_TM=`date +'%H%M'`.log;

Similar as above but with time, and appending the .log extension to the string.

Code:
export FCTN_LIB=${ARCH_BIN_DIR}/function_library.sh

Fills and exports the variable FCTN_LIB with the (undefiend) variable ARCH_BIN_DIR, and appending the filename function_library.sh.

Code:
. ${FCTN_LIB}

Sourcing the above defined file.

Code:
export LOG=${LOG_DIR}/${PROCNAME}.${LOG_DT}${LOG_TM}

Finaly the LOG variable gets filled and exported by appending the above strings together.

Code:
export PFILE=${PROCNAME}.ksh_param

Yet another PFILE variable, which is named the same as the script beeing executed, but having .ksh_param extension, rather than what was originaly.

Code:
PGM=${PROCNAME}

Fill another variable with the basename without file extension to PGM.

Code:
clear

Clear the screen, not that anything was printed yet...

Code:
trap 'errhandle_se_je 1' 1 2 3 15

Trying to trap a function, which was not defined in the given code, while passing 1 2 3 15.
There seems an error, as the first 1 is inside the quote to the function, which probably will cause the function to fail, since its quote, and since there is a space inside the quotes.
Code:
A=${1:-0}
B=${2:-0}  
C=${3:-0}

Filling variable A,B,C with the values of passed arguments 1,2,3 while cut off the 0 tailing chars.

Code:
D=${4:-30}
E=${5:-270}

Same as above, but cutting off 30 (D) or 270 (E) tailing chars (from the right!)

Code:
F="$CDD/${PROCNAME}_dups.bad

Fills the variable F with undefiend variable CDD as path and using PROCNAME (not PGM with the same content) and yet another file extension: .bad.

Hope this helps to get you started
# 11  
Old 04-07-2015
Well, sea,

I had hoped to be specific with the areas that the requester was having problems with, but I believe that there is an error in your explanation for the variables A, B, C, D, E & F.

For A, B & C what you are actually doing (I will use example A) is assigning the variable A with the value of the first passed argument or if it is not set, assigning the variable to zero. So if you called the program with my_prog Hello World then A would become Hello, B would become World and C would be set to zero.

For D & E, the default values (if the 5th & 6th passed arguments are not set) are 30 & 270 respectively.

Variable F is an invalid statement, in that there is no closing double quote.



Additionally, the clear command not only clears the screen, but puts the cursor in the top left corner.


Robin
This User Gave Thanks to rbatte1 For This Post:
Don Cragun (06-10-2015)
# 12  
Old 06-10-2015
Quote:
Originally Posted by Little
I agree Mr rbattle, things are temporary in this world. But dnt you think there are many people who are going to be benefited with this temporary solution too.
Not really. Nobody's going to need the exact same spaghetti code you used to shoehorn expect into this. expect is not a general solution.
Quote:
There are 1000's of post which have the same solution of using ssh key authentication.
And there will be thousands more until people realize "keys weren't just safer, they were simpler and easier in every way. I wasted so much time and thousands of lines of code wrangling expect instead of spending 5 minutes to set up proper keys and use the system the way it was designed."
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Can any one provide shell script for this ... bhavana busetty Shell Programming and Scripting 3 09-14-2014 02:55 PM
How to provide password? vikatakavi Shell Programming and Scripting 1 07-02-2013 04:14 PM
Provide Password using to the application using the shell script GDSR Raju Shell Programming and Scripting 2 11-05-2012 08:26 AM
How the user will provide the parameters for Oracle db connection in a shell script? priya001 Shell Programming and Scripting 6 03-13-2012 06:28 AM
Shell Script to change a user password using script indrajit_renu Shell Programming and Scripting 3 11-23-2010 06:17 AM
How to provide password to the prompt through Java jaibhim Programming 1 11-15-2010 10:57 AM
How to write a shell script for rsync to remote server? Desperados Shell Programming and Scripting 0 06-04-2010 09:57 AM
get around rsync password prompt aarond OS X (Apple) 4 01-10-2010 05:34 AM
rsync - storing password in script stuaz Shell Programming and Scripting 4 12-11-2009 10:47 AM
rsync without password prompt KiranKumarKarre Shell Programming and Scripting 1 05-21-2009 01:41 PM
Shell Script to provide "answers" to SSL Cert Request azvelocat Shell Programming and Scripting 2 04-16-2009 06:10 PM
how to change root password using shell script with standard password kurva Shell Programming and Scripting 2 02-25-2009 01:35 AM
provide a user password from a script solaix14 Shell Programming and Scripting 6 01-06-2009 11:07 AM
password in shell script rajbkriz Shell Programming and Scripting 0 01-23-2008 01:17 AM
calling rsync without promting to input password mandira UNIX for Advanced & Expert Users 1 03-22-2005 04:57 PM