Can some one correct this script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can some one correct this script
# 1  
Old 04-20-2015
Can some one correct this script

Hi,
I tried writing a script and there was a problem with SFTP part
can some one correct where is is the mistake

Enveronment file
Code:
#!/bin/bash
export HOST_NAME=<>
export USER_NAME=<>
export PASSWORD=<>
export SOURCE_PATH=/u03/informatica/current/server/infa_shared/TgtFiles/mfg
export LOCATION_PATH=/u03/informatica/current/server/infa_shared/TgtFiles/mfg
export LOGFILE_DIR=/u03/informatica/current/server/infa_shared/TgtFiles/mfg

Main Script is
Code:
#!/bin/bash
#########################
#MAIL SCRIPT
#########################

. /u03/informatica/.informatica.env
. /u03/informatica/current/server/infa_shared/ScriptFiles/mfg/oa3/CSSS_Etct_File_Tns.env

cd $SOURCE_PATH
echo '$SOURCE_PATH' 

for i in DEES-* ; do
s=`echo $i | cut -d "-" -f3`
echo $s 
result=$(grep -h $s $SOURCE_PATH/csss_file*.txt)
dest_path=`echo $result | cut -d "|" -f2`

echo $dest_path 

sftp $Host_name << end_script
user $User_name $Password
cd $dest_path
put $source_path/*$s*
quit 
end_script

done
exit 0

when i am trying to run this is not going for SFTP and also i need to pass password as parameter

can some one help in correcting me need to delver it in a day

Thanks
Deepu
# 2  
Old 04-20-2015
WHAT exactly is not working? Please be very specific, e.g. contents of variables, directories, line no. that works vs line no that doesn't, error messages.
By sheer looking at it, I can't find anything obvious.
# 3  
Old 04-20-2015
sftp cannot take password as a parameter. It -- and nearly all other login methods such as ssh, scp, su and sudo -- are specifically designed to prevent you from doing this because it's an extremely bad idea.

You will need to set up keys.
This User Gave Thanks to Corona688 For This Post:
# 4  
Old 04-20-2015
Thanks
for the reply....

can u please send me the scp how to use and how to pass password as a peremeter for scp

i tried this
scp -2v $SOURCE_PATH/*$s* $USER_NAME@$HOST_NAME@$PASSWORD:$dest_path

but it is not working

---------- Post updated at 01:00 PM ---------- Previous update was at 12:08 PM ----------

Quote:
Originally Posted by RudiC
WHAT exactly is not working? Please be very specific, e.g. contents of variables, directories, line no. that works vs line no that doesn't, error messages.
By sheer looking at it, I can't find anything obvious.

SFTP is not functioning in the above script and it is not taking the perameters give and how to pass password as verable

if not please correct the scp part what i have used to pass perameter as verable
# 5  
Old 04-20-2015
Quote:
Originally Posted by spradeep86
Can you please send me the scp how to use and how to pass password as a parameter for scp?
You don't.

It's designed so you can't.

Even if it could, it'd be an extremely bad idea. It's preventing you from doing this as a security feature. Plaintext passwords are almost impossible to keep safe!

You need to investigate keys, as I suggested earlier.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

2. Shell Programming and Scripting

Please Correct My script

############### #filename.sh ############### CUREENT_DATE=02 log_file_path="$CUREENT_DATE"-"${0##%*/}`|cut -d "." -f1|awk -F "/" '{print $NF}'`"".log" echo $log_file_path ################ #output required 02-filename.log (6 Replies)
Discussion started by: mohitmehral
6 Replies

3. Shell Programming and Scripting

Can anyone correct the error in this script

ret=`sqlplus -s /nolog << EOF connect $db_user/$db_pwd@$db_sid; SPOOL ./$DirectoryName/TableData.txt; set pagesize 0 feedback off verify off heading off echo off linesize 150 while read var_ack_party_name do select * from bus_event where ack_party_name like... (13 Replies)
Discussion started by: rkrish
13 Replies

4. Shell Programming and Scripting

Please correct the error in the following script

#!/bin/ksh db_user=$DB_USER_NAME db_pwd=$DB_PASSWORD db_sid=$TWO_TASK if ; then echo "\tUsage: MoveUsageProcessing <BC Log file Name>" exit 1 else BCLogFileName=$1 fi grep -i 'MoveUsage daemon needs to run on this account before it can be billed' $1 |awk -F\| '{for(i=0;++i<=NF;) if($i ~... (1 Reply)
Discussion started by: Rajesh Putnala
1 Replies

5. Emergency UNIX and Linux Support

Please correct my script

Please correct my script if it any exceptional, since im calling other external script with in my script. #!/bin/bash FE1=TMM DT1=/home/myHome/dated_1 REPORT=/home/otherHome/Report.sh ## Run the report for FE1 & DT1 cd /home/myHome SERV_LST=/home/myHome/srvc-lst echo "Welcome to... (5 Replies)
Discussion started by: raghunsi
5 Replies

6. Shell Programming and Scripting

something is not write in the script. Can some one please correct this.

Wrong post (2 Replies)
Discussion started by: tuffEnuff
2 Replies

7. Shell Programming and Scripting

Please correct my Script

I am new to awk, can somone please correct the following script awk -F "," 'BEGIN { foreach ((getline < "file1.csv") > 0) {i++ a=1 --> assuming the first column in the row will be stored in a foreach (a in f1) { if (a == $5) continue print a; } } } file2.csv' Here is what I... (11 Replies)
Discussion started by: nuthalapati
11 Replies

8. Shell Programming and Scripting

Is the script correct ???

Dear Collegues is the below given is correct ? #!/usr/bin/perl $a = @ARGV; while ($a = @ARGV) { exec "./jagan ../dat/ml_in @ARGV"; } Jagan (0 Replies)
Discussion started by: jaganadh
0 Replies

9. Shell Programming and Scripting

Please Correct this Array Script

Here is the script. I am not able to increment and Print echo "2=" ${arr} (Bold line) Can someone please help me correct it? I am thinking there is some escape sequence error. Just started learning scripts ... Thanks #!/bin/ksh set -A arr a1 a2 a3 a4 # START Server1=gmi ... (6 Replies)
Discussion started by: psreddy1234
6 Replies
Login or Register to Ask a Question