Home » Infrastructure » Unix » How to pass the password for SCP/SFTP shell scripts in batch mode
icon5.gif  How to pass the password for SCP/SFTP shell scripts in batch mode [message #212275] Thu, 04 January 2007 08:11 Go to next message
rr9876r
Messages: 12
Registered: April 2005
Junior Member
Hey,
I have a shell script, which uses SCP/SFTP to copy the couples files from remote server to local server. It works in interactive mode because I am supplying the password. But not in non-interactive (batch) mode. Is there way to pass the password to the shell script?

Note: I don't like to use Rsync in this case.

Thanks for your help
Re: How to pass the password for SCP/SFTP shell scripts in batch mode [message #232988 is a reply to message #212275] Tue, 24 April 2007 06:30 Go to previous messageGo to next message
avdhesh
Messages: 4
Registered: March 2002
Junior Member
Can you help me with this?

I want to redirect a sql script to another server mean want to ftp it to another server.My script is below but it's not working.
Please help me

#! /bin/sh
export ORACLE_USER=apps
export ORACLE_PASSWORD=sma1db07
export DB_NAME=SMAXDEVL

export CONNSTRING=${ORACLE_USER}/${ORACLE_PASSWORD}@${DB_NAME}

$ORACLE_HOME/bin/sqlplus -s $CONNSTRING <<!

@sf1.sql >>/tmp/sf.txt

#exit;
#EOF

ftp 10.32.25.73
bin
put /tmp/sf.txt
bye
EOF
Re: How to pass the password for SCP/SFTP shell scripts in batch mode [message #242446 is a reply to message #212275] Sat, 02 June 2007 03:18 Go to previous messageGo to next message
nmacdannald
Messages: 460
Registered: July 2005
Location: Stockton, California - US...
Senior Member
As far as I know you must start the in the ORACLE_HOME of the database you want to use. When you log onto the system as the owner of a database it uses the .profile to set ORACLE_HOME and other parameters appropriately. At least one exception are database links, I sure there must be others. Otherwise we are getting into uucp type commands. Not really sure it is wise to allow passwords to be passed around in clear text.
Re: How to pass the password for SCP/SFTP shell scripts in batch mode [message #242472 is a reply to message #212275] Sat, 02 June 2007 08:51 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
untested code to follow:
#! /bin/sh
export ORACLE_USER=apps
export ORACLE_PASSWORD=sma1db07
export DB_NAME=SMAXDEVL
export CONNSTRING=${ORACLE_USER}/${ORACLE_PASSWORD}@${DB_NAME}
$ORACLE_HOME/bin/sqlplus -s $CONNSTRING <<STOP
spool /tmp/sf.txt
@sf1.sql 
exit
STOP
ftp 10.32.25.73 <<EOF
bin
put /tmp/sf.txt
bye
EOF
Previous Topic: Creating file using UNIX K-Shell Scripts.
Next Topic: ORA-01033: ORACLE initialization or shutdown in progress
Goto Forum:
  


Current Time: Tue Apr 16 06:22:04 CDT 2024