Unix/Linux Go Back    


Emergency UNIX and Linux Support Please post your urgent questions here for highest visibility. Posting a new thread to this forum requires Bits. We monitor this forum to help people with emergencies, but we do not guarantee response time or answers. This forum is "best effort" only. Members who reply to posts here receive a bonus of 1000 Bits per reply.

How to provide password for rsync in shell script?

Emergency UNIX and Linux Support


Tags
rsync, unix

Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 03-26-2015   -   Original Discussion by Little
laasyateradata's Unix or Linux Image
laasyateradata laasyateradata is offline
Registered User
 
Join Date: Mar 2015
Last Activity: 26 March 2015, 10:23 PM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
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 07:03 AM.. Reason: Added CODE tags
Sponsored Links
    #9  
Old Unix and Linux 04-07-2015   -   Original Discussion by Little
rbatte1's Unix or Linux Image
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 19 February 2018, 11:57 AM EST
Location: Lancashire, UK
Posts: 3,487
Thanks: 1,518
Thanked 679 Times in 612 Posts


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
Sponsored Links
    #10  
Old Unix and Linux 04-07-2015   -   Original Discussion by Little
sea's Unix or Linux Image
sea sea is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 14 October 2016, 2:49 PM EDT
Location: Swissh
Posts: 1,286
Thanks: 256
Thanked 226 Times in 209 Posts


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 Unix and Linux 04-07-2015   -   Original Discussion by Little
rbatte1's Unix or Linux Image
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 19 February 2018, 11:57 AM EST
Location: Lancashire, UK
Posts: 3,487
Thanks: 1,518
Thanked 679 Times in 612 Posts
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
The Following User Says Thank You to rbatte1 For This Useful Post:
Don Cragun (06-10-2015)
Sponsored Links
    #12  
Old Unix and Linux 06-10-2015   -   Original Discussion by Little
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 22 February 2018, 2:28 PM EST
Location: Saskatchewan
Posts: 22,614
Thanks: 1,170
Thanked 4,301 Times in 3,968 Posts
Quote:
Originally Posted by Little View Post
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."
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can any one provide shell script for this ... bhavana busetty Shell Programming and Scripting 3 09-14-2014 03:55 PM
Provide Password using to the application using the shell script GDSR Raju Shell Programming and Scripting 2 11-05-2012 09: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 07:28 AM
rsync - storing password in script stuaz Shell Programming and Scripting 4 12-11-2009 11:47 AM
provide a user password from a script solaix14 Shell Programming and Scripting 6 01-06-2009 12:07 PM



All times are GMT -4. The time now is 10:38 PM.