-1

i need a shell script to ask the username and pathe to store the expdp file in a specified path. please help me. below is my script.

#!/bin/sh

STARTTIME=`date`
export ORACLE_SID=test
export ORACLE_HOME=`cat /etc/oratab|grep ^${ORACLE_SID}:|cut -d':' -f2`
export EXPLOG=expdp_${ORACLE_SID}.log
export EXPDIR=/expdir
export PATH=$PATH:$ORACLE_HOME/bin
DATEFORMAT=`date +%Y%m%d`
STARTTIME=`date`

# Data Pump export
expdp  system/manager content=ALL directory=expdir dumpfile=expdp_`echo $ORACLE_SID`_%U_`echo $DATEFORMAT`.dmp full=Y logfile=$EXPLOG
#expdp export/export content=ALL directory=expdir dumpfile=expdp_`echo $ORACLE_SID`_%U_`echo $DATEFORMAT`.dmp schemas=santhosha logfile=$EXPLOG
ENDTIME=`date`

/home/oracle/deleteold.sh > /backup/expdir/deleteold.log 2>&1
4

2 回答 2

1
You can use Without Security :
echo "User name: $0"
echo "Password: $1"

You can use With Security :
read -s -p "Password: " password

$ help read
read: read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
Read a line from the standard input and split it into fields.
  ...
  -p prompt output the string PROMPT without a trailing newline before
            attempting to read
  ...
  -s                do not echo input coming from a terminal
于 2014-03-26T06:40:32.663 回答
1

这应该有助于:

#!/bin/bash

echo "Type the username, followed by [ENTER]:"

read usrname

echo "The name entered was: $usrname"

更新

#!/bin/bash

echo "Type the username, followed by [ENTER]:"

read usrname

echo "Type the path, followed by [ENTER]:"

read pthname

echo "The name entered was: $usrname"
echo "The path entered was: $pthname"

if [ -d "$pthname" ]
then
  echo "$pthname is a directory."
  expdp  system/manager content=ALL directory=$pthname dumpfile=expdp_`echo $ORACLE_SID`_%U_`echo $DATEFORMAT`.dmp full=Y logfile=$EXPLOG
fi

更新 2

于 2014-03-26T06:00:38.393 回答