Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Verification on shell script

Tags
shell scripts

👤 Login to reply

 
Thread Tools Search this Thread
# 1  
Old 09-20-2013
Verification on shell script

hello i have writing a shell script to download and run some packages
the only way that i use to verify download pack is , limit users ip to download from main server, if wget can download file (verified) then script run by execute it sh pack76.sh
else show and error

(stupid solution ha?)

Code:
if [ $answer = y ]; then
	cd $INSTALLDIR
	wget $MIRROR/pack76.sh
	if [ -f $INSTALLDIR/pack76.sh ]
	then
		sh pack76.sh
	else
		echo -e "$RED you dont have permition to download $RESET"
	fi
fi

any idea ?
# 2  
Old 09-20-2013
I am not sure I understand what you mean by
Quote:
verify download pack
What are you trying to download and from where?
Also, I see a few problems with your code, for example:
Code:
$answer = y

is an assignment statement and won't return a boolean value (True or False), which is what you seem to need here.
Second, here
Code:
	if [ -f $INSTALLDIR/pack76.sh ]
	then
		sh pack76.sh
	else
		echo -e "$RED you dont have permition to download $RESET"
	fi

You are checking for the existence of the file pack76.sh (what is this supposed to do and what are its contents, by the way?) and if it doesn't exist you are echoing a message saying that the user doesn't have permission to perform the download operation - I believe you should have checked for permissions along with existence.
But I'm afraid I can't tell for sure just by looking at the code snippet you included in your post.
Please provide more details and a concise explanation of what you're trying to accomplish, along with the source code that you're already tried and any problems you may have encountered in the process.
# 3  
Old 09-20-2013
tnq gacanepa

i have copy part of my code that need to open this topic,
ok let me explain how i have verify :
i have add .htaccess on $mirror so if untruest machine send request to download package,only allow ip which add on .htaccess will permit to download,
i will add ips manually.

then if command will check, is file download and exist or not
if wget coud download file (allow) yes, it will open package and compile it, else, it will show warning
main part of verification is :

Code:
wget $MIRROR/pack76.sh
	if [ -f $INSTALLDIR/pack76.sh ]
	then
		sh pack76.sh
	else
		echo -e "$RED you dont have permition to download $RESET"
	fi

# 4  
Old 09-20-2013
I insist that checking the existence of a file is not the best way to allow or deny its execution.
What I would do is wget the file, then if that command completed successfully I'd start the download operation, otherwise I'd show the error message, more like so:
Code:
wget $MIRROR/pack76.sh
	if [ $? == 0 ]
	then
		sh pack76.sh
	else
		echo -e "$RED The download cannot be performed $RESET"
	fi

Hope it helps.
The Following User Says Thank You to gacanepa For This Useful Post:
nimafire (09-20-2013)
# 5  
Old 09-20-2013
I get the point of the thread owner..., what I dont understand is since he knows who are allowed ( IP list...) why not test if you are allowed to download?
The Following User Says Thank You to vbe For This Useful Post:
gacanepa (09-20-2013)
# 6  
Old 09-20-2013
Quote:
Originally Posted by vbe
I get the point of the thread owner..., what I dont understand is since he knows who are allowed ( IP list...) why not test if you are allowed to download?
mm i want to publish my script so i need verification method to know who use this script
i have not find any solution to encode-decode shell scripting so i use ip restriction by allow and deny

---------- Post updated at 02:18 PM ---------- Previous update was at 02:12 PM ----------

Quote:
Originally Posted by gacanepa
I insist that checking the existence of a file is not the best way to allow or deny its execution.
What I would do is wget the file, then if that command completed successfully I'd start the download operation, otherwise I'd show the error message, more like so:
Code:
wget $MIRROR/pack76.sh
	if [ $? == 0 ]
	then
		sh pack76.sh
	else
		echo -e "$RED The download cannot be performed $RESET"
	fi

Hope it helps.
good idea
so shell scripting do not have any protection like i need?
so what shell programmer do?
# 7  
Old 09-20-2013
Code:
[ $answer = y ]

is not an assignment, and works with all sh-type shells.
But eventually give a test syntax error when $answer is empty or multi-word. Safe is
Code:
[ "$answer" = y ]

While
Code:
[ "$answer" == y ]

is an extension of the test command - not portable.
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SHA1 verification script Ardzii OS X (Apple) 2 02-15-2017 06:30 AM
ECDSA verification dragonpoint Programming 0 05-24-2016 08:56 PM
Help about comment verification learnbash Shell Programming and Scripting 5 01-28-2014 04:42 AM
Field verification script help galford Shell Programming and Scripting 2 10-31-2013 03:32 PM
Script Verification k33k00 Shell Programming and Scripting 1 04-07-2012 07:32 AM
Script for verification of Data corruption manish_tcs_hp Shell Programming and Scripting 4 12-07-2010 08:14 PM
htable + verification kamel.seg Programming 0 06-17-2008 06:02 AM
Email address verification script Ramdas Shell Programming and Scripting 4 01-15-2007 01:51 AM
Verification of a script already running - where to do it miwinter UNIX for Dummies Questions & Answers 2 08-07-2006 10:32 AM
verification? sheranjem UNIX for Dummies Questions & Answers 3 06-06-2005 01:08 PM


All times are GMT -4. The time now is 08:46 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password