cancel
Showing results for 
Search instead for 
Did you mean: 

Command line parameters and Shell Script -- URGENT

Former Member
0 Kudos

Hi folks,

I am facing some problem in the Shell script and the command line parameter.

The scenario is -- I am picking a file from a directory, whose path is <b>/interfaces/xid/receive/filename.dat</b>

I have to encrypt filename.dat and move it to another folder, whose path is <b>/interfaces/xid/send</b>. So, the encrypted file will reside in the <b>send</b> directory.

Now, I don't want to hardcode the new path, where the encrypted file has to be moved. Please let me know how to achieve this. Please consider this as urgent.

Have a look at the command line in the "before message processing" -- <b>/interfaces/xid/receive/xi_decompress.sh /interfaces%F</b>

Have a look at the shell script for the same --

#!/bin/sh

#----


  1. Setup environment variables

#----


COMMPRESS_DIR=/interfaces/software/commpress

export COMMPRESS_DIR

LOG_DIR=/interfaces/software/commpress/log/

export LOG_DIR

IN_FILE=$1

export IN_FILE

  1. Find the directory where the unencrypted file is deposited

IN_FILE_DIR=`dirname $1`

export IN_FILE_DIR

  1. Make sure the working directory is where the unencrypt.key is...

cd $COMMPRESS_DIR

  1. encrypt the file

if [ `uname` = "HP-UX" ]

then

find $IN_FILE | $COMMPRESS_DIR/compx $IN_FILE_DIR logpath=$LOG_DIR

else

find $IN_FILE | $COMMPRESS_DIR/compx-sun $IN_FILE_DIR logpath=$LOG_DIR

fi

  1. Get the result of the encryption

RET_CODE=$?

  1. Check decryption result

  2. If error (retuen code <> 0), create an error log file in the

  3. same directory as the input file.

if [ $RET_CODE -ne 0 ]

then

PREFIX="Decryption"

DATE_TIME=$(date +%Y%m%d_%H%M%S%N)

SUFFIX="err"

FILENAME=$/$_$.$ echo "Decryption Error log" >$FILENAME echo "DATE_TIME: $" >>$FILENAME echo "DIRECTORY: $" >>$FILENAME

echo "FILE: $" >>$FILENAME

echo "ERROR CODE: $" >>$FILENAME

fi

exit $RET_CODE

-


What else I need to add in this piece of code? Urgent help !!

Thanks a lot in advance.

Neetesh

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Raj,

I think if you pass the directory where to be moved and the filename to be encrypted to the shell script you should be able to resolve your issue. But if you dont pass the directory then I dont think it is possible.

Regards,

---Satish

Former Member
0 Kudos

Hi Satish,

<i>if you pass the directory where to be moved and the filename to be encrypted</i>

So you mean to say that I should hard code the path of the directory?

Please clarify.

Thanks,

Neetesh

Former Member
0 Kudos

Yes Raj.

Regards,

---Satish

Former Member
0 Kudos

Hi Satish,

I was able to figure that out, that we need to hard code the path as the 2nd parameter.

But I guess there is a way out in Unix where we can handle this situation, where we are not willing to hard code.

Anyways, thanks a lot for your input .. -:)

Cheers,

Neetesh

Former Member
0 Kudos

Sorry, there is a typo error .. in the script, PREFIX="Decryption" should be replaced by <b>PREFIX="Encryption"</b>

Thanks,

Neetesh