The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Government Security Standard Compliant Kickstarts 0.01 (Default branch) iBot Software Releases - RSS News 0 04-19-2008 03:30 AM
How to sort standard input without first line < Header > pp56825 Shell Programming and Scripting 8 03-26-2008 02:25 PM
How to copy from standard input lalelle Shell Programming and Scripting 2 08-24-2007 04:36 AM
permanent redirection of standard input gfhgfnhhn Shell Programming and Scripting 6 11-01-2006 04:52 AM
standard input Jariya Shell Programming and Scripting 1 06-06-2006 12:49 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2006
yall yall is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 8
Security Issue with Standard Input?

Hi Gang,

Running a script in AIX 5.3. Users wanted me to add a "confirm you want to run script, enter 'y' or 'n'" kind of thing... here is what I came up with:

#!/bin/sh

myfile=`basename "$1"`
dateNow=`date "+%m.%d.%Y.%H.%M.%S"` # Get current date
mydatedfile=$myfile.$dateNow
appfolder="/home/43168134/prod"
newfolder="/home/43168134/arch"

echo "Are you sure you want to approve $myfile ?"
echo ""
echo "Okay?("Y" or "N")=> "
set ret = "$<"
if ("$ret" != "y" && "$ret" != "Y") then
echo ""
echo ""
echo "End."
exit 0
else
if [ -s "$myfile" ]; then
mv "$myfile" "$appfolder/$myfile" # Move file to another folder
cp -p "$appfolder/$myfile" "$newfolder/$mydatedfile" # Copy file with new archive name
print "$myfile has been moved to Production and Archived."
else
print "$myfile does not exist or is empty."
exit 1
fi
fi
exit 0


When I run the script, I get this:

$ approveTEST.sh CallidusFile3.csv
Are you sure you want to approve CallidusFile3.csv ?

Okay?(Y or N)=>
approveTEST.sh[13]: : 0403-006 Execute permission denied.
CallidusFile3.csv has been moved to Production and Archived.


The script does the move/copy OK, but won't accept any input and instead gives me an error. I did chmod 755 and 744 hoping that would fix it, but no luck.

Any thoughts?

Thanks in advance...
  #2 (permalink)  
Old 10-10-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Try changing
Code:
if ("$ret" != "y" && "$ret" != "Y") then

to
Code:
if [ "$ret" != "y" -a "$ret" != "Y" ]; then

Also, please use code tags.
  #3 (permalink)  
Old 10-10-2006
yall yall is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 8
Will do going forward...

I'll give your fix a try... Thanks!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0