Visit Our UNIX and Linux User Community

Shell script to encrypt the xls file using executable jar in Linux SUSE 11.4

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to encrypt the xls file using executable jar in Linux SUSE 11.4
# 1  
Old 04-25-2016
Shell script to encrypt the xls file using executable jar in Linux SUSE 11.4

Dear Experts,

I am an ERP consultant and would like to learn shell script. We are working on Linux SUSE 11.4 and I am very new to shell scripting. We can manually encrypt an excel file using "executable jar" through command prompt by placing the jar file & the file to be encrypted on a physical path and the same need to achieved using shell script in Linux which will be later called by middle ware tool to encrypt the file automatically instead of manual. I have the server access, can you please guide me to achieve this as early as possible.

The command used in cmd is

java –jar  <<name of jar file>>.jar  <<full path of the file>>

Please help me to achieve this.


Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 04-25-2016 at 10:55 AM..
# 2  
Old 04-25-2016
Assuming that you're using a POSIX-conforming shell (such as ash, bash, date, ksh, or zsh), you just need to put your commands in a file with a little bit of shell script boilerplate, parameterize the part(s) of the command that need to be supplied on the command-line when you invoke your script, add some error checking to be sure that the needed command-line arguments are present when your script is invoked, make the script executable, and put it in a directory where the people who need to execute your script will be able to find it.

I prefer the Korn shell, so I will use it for this example, but the code supplied here will work with any POSIX-conforming shell if there is some reason why you don't like the Korn shell. First place the following text in a file named whatever name you want to use when you invoke this script. (I'll assume that you named it makejar in the following directions.) Note that you must use an editor that uses the <newline> character as the line terminator (not the DOS <carriage-return><newline> character pair) when you create this file:
# Save last component of pathname used to invoke this script for use in diagnostic messages.

# Verify that we were invoked with two operands.
if [ $# -ne 2 ]
then	# Print usage message to stderr and exit.
	printf 'Usage: %s name_of_jar_file file_pathname\n' "$IAm" >&2
	exit 1

# Allow 1st operand to be specified with or without ".jar".

# Run the desired command...
java -jar  "$jar_file"  "$path"

Then make the file executable:
chmod +x makejar

Assuming that this command is for your personal use, move it into your bin directory (creating it if it doesn't already exist):
mkdir -p $HOME/bin
mv makejar $HOME/bin

Then, assuming that $HOME/bin is in your PATH environment variable, you can execute your script just by typing its name and the parameters you want to pass to it just as you would with any other command you give to your shell:
makejar myjar /path/to/myjar

makejar myjar.jar /path/to/myjar

Previous Thread | Next Thread
Test Your Knowledge in Computers #887
Difficulty: Easy
sed (stream editor) is a Unix utility that parses and transforms text, using a simple, compact programming language.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Encrypt Password file and decrypt in a shell script

Hi All, I have stored Oracle database passwords in a hidden file - .pass_file. My shell script reads the hidden file, gets the password and then logs in to the Oracle database and runs some SQL script. My requirement is: I need to provide the shell script to be executed by someone else. So,... (1 Reply)
Discussion started by: sunpraveen
1 Replies

2. UNIX for Advanced & Expert Users

Shell script for dealing with XLS file with multiple tabs/worksheets

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (2 Replies)
Discussion started by: himanshu sood
2 Replies

3. UNIX for Dummies Questions & Answers

Download .xls file from mail and copy to another path using shell script

Hi I have a mail attachment coming from a mail id and evreytime with the same name in .xls format.I have to download the .xls file into a location and convert it itno .csv format and copy the .csv file to another location. (1 Reply)
Discussion started by: bikky6
1 Replies

4. Shell Programming and Scripting

Encrypt shell script

Hi, We have some scripts which will run in other project..So the requirement is that we dont want that they should see our code though they can run it. I have done some searching about how to encrypt the shell script and found SHC utillity as the answer. Can anybody please suggest how will... (11 Replies)
Discussion started by: millan
11 Replies

5. Shell Programming and Scripting

how to encrypt a password in shell script

Hi, I have run the below script which is connected to db2 v9.5. There is no issue. The only problem is how to encrypt the dbpwd? #!/bin/ksh #---- Set Environment dbalias="dev1db" dbuser="user1" dbpwd="password" #---- Connect to the Database cd /opt/ibm/db2/V9.5/bin db2 "connect to... (1 Reply)
Discussion started by: lookinginfo
1 Replies

6. Shell Programming and Scripting

Create Jar using shell script

Hi Folks I came up with peculiar requierement ..:) I have to jar special files types only from a number of child folders , and also exactly same as the child file path...sorry i will give an example suppose i have following folder structure # cd HTML/ total 0 drwxrwxr-x 2... (1 Reply)
Discussion started by: johnycage
1 Replies

7. Shell Programming and Scripting

shell script encrypt a file using gpg

Hi, I have a requirement to encrypt a file using gpg with a public key. However when i encrypt a file, i get a question like 'Do you want to go ahead with unverified user?' . when i press 'y' file is encrypted. I am not able to automate this job because of this interactive mode. Could... (3 Replies)
Discussion started by: Deepakbabu
3 Replies

8. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

9. Shell Programming and Scripting

how to encrypt my shell script program in linux

for security purpose I want to encrypt my shell script program.please give me some idea immediately. I have already try SHC in my server but after using SHC server hang problem is occured. kindly provide me solution for that. akm (3 Replies)
Discussion started by: akm9999
3 Replies

Featured Tech Videos