1 2 Previous Next 20 Replies Latest reply: Jan 18, 2013 6:28 AM by Catch_22 RSS

    Issue in Unix Shell script

    Bopty
      Hi,

      To Archive files, I try to move files from one directory to another directory . So i used the below logic,

      *#!/bin/ksh*

      *****Archive*****

      *mv ${DATA_DIR}/ABC_*.dat ${ARCHIVE}*

      So if i give the complete file name its working fine. But if i use '*', im getting the below error,

      mv: cannot stat `PATH`: : No such file or directory

      Please help me in this.


      Thanks,
      Bopty

      Edited by: Bopty on Jan 3, 2013 11:39 AM
        • 1. Re: Issue in Unix Shell script
          moreajays
          Hi,

          "*" is unable to locate the exact directory , add echo $ARCHIVE before "mv" to check of it is picking correct path

          Thanks,
          Ajay More
          • 2. Re: Issue in Unix Shell script
            Bopty
            Hi Ajay,

            Thanks for your Reply.

            Yes, i used in my code, its showing the correct path only. The thing is if i give full file name its working fine.

            But if i use '*' in my file name its not working :(

            e.g: ABC_*.dat


            Thanks,
            Bopty
            • 3. Re: Issue in Unix Shell script
              moreajays
              Hi,

              Try below two options one by one
              mv ${DATA_DIR}/ABC_.dat ${ARCHIVE}/*
              
              mv ${DATA_DIR}/ABC_.dat ${ARCHIVE}/\*
              Thanks,
              Ajay More
              • 4. Re: Issue in Unix Shell script
                Osama_Mustafa
                Similar thread , Same problem
                http://www.unix.com/unix-advanced-expert-users/211641-not-working-shellscript.html
                • 5. Re: Issue in Unix Shell script
                  Bopty
                  Hi Ajay,

                  Sorry, Confusion happend in the file mv command think, here is the mv command which is use in the shell script,

                  mv ${DATA_DIR}/ABC_*.dat ${ARCHIVE}


                  Thanks,
                  Bopty

                  Edited by: Bopty on Jan 3, 2013 12:19 PM
                  • 6. Re: Issue in Unix Shell script
                    Bopty
                    Osama_mustafa wrote:
                    Similar thread , Same problem
                    http://www.unix.com/unix-advanced-expert-users/211641-not-working-shellscript.html
                    Hi Osama,

                    It was posted by me only :)

                    Thanks,
                    Bopty

                    Edited by: Bopty on Jan 3, 2013 2:31 PM
                    • 7. Re: Issue in Unix Shell script
                      moreajays
                      Hi,

                      Then try below
                      mv ${DATA_DIR}/ABC_\*.dat ${ARCHIVE}
                      
                      mv ${DATA_DIR}/ABC_\*.dat ${ARCHIVE}/
                      
                      mv ${DATA_DIR}/ABC_\*.dat ${ARCHIVE}/\*
                      Thanks,
                      Ajay More
                      • 8. Re: Issue in Unix Shell script
                        Bopty
                        Tried all the combinations. Still showing the error :(

                        mv: cannot stat `ABC_*': No such file or directory


                        Thanks,
                        Boopathy
                        • 9. Re: Issue in Unix Shell script
                          moreajays
                          Hi,

                          Can you set below in the script give us o/p

                          ls -lrt ${DATA_DIR}/ABC_*.dat
                          ls -lrt ${DATA_DIR}/ABC_\*.dat
                          ls -lrt ${DATA_DIR}/
                          echo "${DATA_DIR}/ABC_\*.dat"
                          echo "${DATA_DIR}/ABC_*.dat"

                          Thanks,
                          Ajay More
                          • 10. Re: Issue in Unix Shell script
                            Bopty
                            Tried already, even in ls also * is not working.

                            For echo its showing complete "DATA_DIR path\ABC_*"
                            • 11. Re: Issue in Unix Shell script
                              moreajays
                              hi ,

                              Can you change the shell to #!/bin/sh & try.
                              also add set -x in shell & paste complete o/p here


                              Thanks,
                              Ajay More
                              • 12. Re: Issue in Unix Shell script
                                Bopty
                                +++ basename /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/src/XXXXXX.ksh .ksh
                                ++ export PROGRAM_NAME=XXXXXX
                                ++ PROGRAM_NAME=XXXXXXX
                                ++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/rmse_rpas_config.env
                                +++ file_name=
                                +++ skip_txt_files=0
                                +++ redirection_flg=1
                                +++ ignore_status_file=0
                                +++ vdate_if_avail_flg=1
                                +++ force_curr_date_flg=0
                                +++ '[' '' = -e ']'
                                +++ '[' '' = -t ']'
                                +++ '[' '' = -r ']'
                                +++ '[' '' = -s ']'
                                +++ '[' '' = -v ']'
                                +++ '[' '' = -c ']'
                                ++++ echo
                                ++++ awk '{print substr($1,1,1)}'
                                +++ first_char=
                                +++ '[' '' '!=' - ']'
                                +++ file_name=
                                +++ DATE_TYPE=vdate
                                +++ export DBNAME=RMSDEV
                                +++ DBNAME=RMSDEV
                                +++ export RMS_OWNER=RMSDEV
                                +++ RMS_OWNER=RMSDEV
                                +++ export BA_OWNER=RMSDEV
                                +++ BA_OWNER=RMSDEV
                                +++ export DBHOST=192.168.280.160
                                +++ DBHOST=192.168.280.160
                                +++ export DBPORT=1525
                                +++ DBPORT=1525
                                +++ export RETL_WALLET_ALIAS=RMSDEV
                                +++ RETL_WALLET_ALIAS=RMSDEV
                                +++ export ORACLE_WALLET_ALIAS=RMSDEV
                                +++ ORACLE_WALLET_ALIAS=RMSDEV
                                +++ export SQLPLUS_LOGON=/@RMSDEV
                                +++ SQLPLUS_LOGON=/@RMSDEV
                                +++ export LOC_ATTRIBUTES_ACTIVE=False
                                +++ LOC_ATTRIBUTES_ACTIVE=False
                                +++ export PROD_ATTRIBUTES_ACTIVE=False
                                +++ PROD_ATTRIBUTES_ACTIVE=False
                                +++ export DIFFS_ACTIVE=True
                                +++ DIFFS_ACTIVE=True
                                +++ '[' True = True ']'
                                +++ '[' False = True ']'
                                +++ '[' False = True ']'
                                +++ export ISSUES_ACTIVE=True
                                +++ ISSUES_ACTIVE=True
                                +++ export LOAD_TYPE=CONVENTIONAL
                                +++ LOAD_TYPE=CONVENTIONAL
                                +++ export DB_ENV=ORA
                                +++ DB_ENV=ORA
                                +++ export CONN_TYPE=thin
                                +++ CONN_TYPE=thin
                                +++ NO_OF_CPUS=4
                                +++ export LANGUAGE=en
                                +++ LANGUAGE=en
                                +++ set -f
                                +++ rm -f /u01/data/oracle/RETL_HOME/tmp/rfx.log
                                +++ export RETL_EXE=rfx
                                +++ RETL_EXE=rfx
                                +++ export RFX_EXE=rfx
                                +++ RFX_EXE=rfx
                                +++ export 'RETL_OPTIONS=-c /u01/data/oracle/RETL_HOME/etc/rfx.conf -s SCHEMAFILE -f -'
                                +++ RETL_OPTIONS='-c /u01/data/oracle/RETL_HOME/etc/rfx.conf -s SCHEMAFILE -f -'
                                +++ export 'RFX_OPTIONS=-c /u01/data/oracle/RETL_HOME/etc/rfx.conf -s SCHEMAFILE'
                                +++ RFX_OPTIONS='-c /u01/data/oracle/RETL_HOME/etc/rfx.conf -s SCHEMAFILE'
                                +++ export DATA_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
                                +++ DATA_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
                                +++ export REJ_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
                                +++ REJ_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
                                +++ export LOG_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/log
                                +++ LOG_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/log
                                +++ export ERR_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error
                                +++ ERR_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error
                                +++ export ARCH_DIR=/u01/data/oracle/rms/UPGRMSBATCH/archive
                                +++ ARCH_DIR=/u01/data/oracle/rms/UPGRMSBATCH/archive
                                +++ export RSC_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/include
                                +++ RSC_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/include
                                +++ export SCHEMA_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/schema
                                +++ SCHEMA_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/schema
                                +++ export BIN_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/bin
                                +++ BIN_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/bin
                                +++ export LIB_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib
                                +++ LIB_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib
                                +++ export ETC_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc
                                +++ ETC_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc
                                +++ export SRC_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/src
                                +++ SRC_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/src
                                +++ export BKM_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/bookmark
                                +++ BKM_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/bookmark
                                +++ export TEMP_DIR=/u01/data/oracle/RETL_HOME/tmp
                                +++ TEMP_DIR=/u01/data/oracle/RETL_HOME/tmp
                                +++ export NLS_NUMERIC_CHARACTERS=.,
                                +++ NLS_NUMERIC_CHARACTERS=.,
                                +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_get_var.ksh
                                +++ '[' 0 -eq 1 ']'
                                +++ '[' vdate = vdate ']'
                                +++ '[' -s /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/vdate.txt ']'
                                ++++ cat /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/vdate.txt
                                +++ export VDATE=20121208
                                +++ VDATE=20121208
                                +++ '[' vdate = current_date ']'
                                +++ '[' vdate = vdate ']'
                                +++ export FILE_DATE=20121208
                                +++ FILE_DATE=20121208
                                +++ export LOG=20121208.log
                                +++ LOG=20121208.log
                                +++ export LOG_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/log/20121208.log
                                +++ LOG_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/log/20121208.log
                                +++ '[' '' '!=' '' ']'
                                +++ export ERR_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error/XXXXXXX.20121208
                                +++ ERR_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error/XXXXXXX.20121208
                                +++ export REJ_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/XXXXXXX.rej.20121208
                                +++ REJ_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/XXXXXXX.rej.20121208
                                +++ export STATUS_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error/XXXXXXX.status.20121208
                                +++ STATUS_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error/XXXXXXX.status.20121208
                                +++ export BOOKMARK_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/bookmark/XXXXXXX.bkm.20121208
                                +++ BOOKMARK_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/bookmark/XXXXXXX.bkm.20121208
                                ++++ date
                                +++ echo '\n****** STARTING XXXXXXX: Thu Jan 3 02:57:09 EST 2013 ******\n'
                                +++ '[' '!' -f /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error/XXXXXXX.status.20121208 ']'
                                +++ touch /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/error/XXXXXXX.status.20121208
                                +++ '[' 1 -eq 1 ']'
                                +++ exec
                                • 13. Re: Issue in Unix Shell script
                                  Bopty
                                  i hope this is what you needed,

                                  +++ export MULTI_CURRENCY_IND=Y
                                  +++ MULTI_CURRENCY_IND=Y
                                  +++ '[' Y = ERROR ']'
                                  ++++ rmse_get_var prime_currency_code.txt
                                  ++++ '[' -s /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/prime_currency_code.txt ']'
                                  +++++ cat /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/prime_currency_code.txt
                                  ++++ echo GBP
                                  ++++ return
                                  +++ export PRIME_CURRENCY_CODE=GBP
                                  +++ PRIME_CURRENCY_CODE=GBP
                                  +++ '[' GBP = ERROR ']'
                                  ++++ rmse_get_var prime_exchng_rate.txt
                                  ++++ '[' -s /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/prime_exchng_rate.txt ']'
                                  +++++ cat /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/prime_exchng_rate.txt
                                  ++++ echo 1.000000
                                  ++++ return
                                  +++ export PRIME_EXCHNG_RATE=1.000000
                                  +++ PRIME_EXCHNG_RATE=1.000000
                                  +++ '[' 1.000000 = ERROR ']'
                                  ++++ rmse_get_var consolidation_code.txt
                                  ++++ '[' -s /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/consolidation_code.txt ']'
                                  +++++ cat /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/etc/consolidation_code.txt
                                  ++++ echo O
                                  ++++ return
                                  +++ export CONSOLIDATION_CODE=O
                                  +++ CONSOLIDATION_CODE=O
                                  +++ '[' O = ERROR ']'
                                  ++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_lib.ksh
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_analyze_tbl.ksh
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_error.ksh
                                  ++++ export REJ_FILELIST=
                                  ++++ REJ_FILELIST=
                                  ++++ export REJ_FILECNT=0
                                  ++++ REJ_FILECNT=0
                                  ++++ trap rmse_terminate INT TERM KILL
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_message.ksh
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_drop_tbl.ksh
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_log_num_recs.ksh
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_simple_extract.ksh
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_extract_with_schema.ksh
                                  +++ . /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/lib/rmse_rpas_query_db.ksh
                                  ++ echo /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
                                  /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
                                  ++ mv '/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_*.dat' '/u01/data/oracle/rms/UPGRMSBATCH/archive/*'
                                  mv: cannot stat `/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_*.dat': No such file or directory
                                  ++ echo /u01/data/oracle/rms/UPGRMSBATCH/archive
                                  /u01/data/oracle/rms/UPGRMSBATCH/archive
                                  +++ date +%d%m%y%H%M%S
                                  ++ timestamp=030113025709
                                  ++ export OUTPUT_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113025709.dat
                                  ++ OUTPUT_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113025709.dat
                                  ++ export OUTPUT_SCHEMA=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/schema/XXXXX.schema
                                  ++ OUTPUT_SCHEMA=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/rfx/schema/XXXXX.schema
                                  ++ message 'Program started ...'
                                  +++ date +%T
                                  ++ echo 'XXXXX 02:57:09: Program started ...'
                                  ++ echo '\n-----------------------------'
                                  \n-----------------------------
                                  +++ date +%T
                                  ++ echo 'XXXXX 02:57:09: Program started ...'
                                  XXXXX 02:57:09: Program started ...
                                  ++ echo -----------------------------
                                  -----------------------------
                                  ++ FLOW_FILE=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/log/XXXXX.xml
                                  ++ cat
                                  • 14. Re: Issue in Unix Shell script
                                    moreajays
                                    can u paste o/p of below manually not from script

                                    ls -lrt /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_*.dat
                                    1 2 Previous Next