|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I want to take the file name as an input to the program and copy that file into new location using shell. Below program is not working properly. Code:
#!/bin/sh
if [ $file != '']; then
`/usr/bin/perl -pi -e's/(notifications_enabled\s*)(\d+)/$sub = "$1" . ("$2"== "0" ? "1":"0")/e; ' $file`
`cp /script/test/123/$file /etc/hosts/`
fi
case $1 in
'file') echo $file ;;
*) echo "Usage: $0 specify file name" ;;
esacLast edited by Franklin52; 02-04-2013 at 05:11 AM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Why are you putting everything in backticks `` ? That is not correct, they are pointless here and probably spew errors too. You probably want positional parameters here. If someone calls your script with myscript filename then filename will be $1. Code:
if [ -z "$1" ]
then
echo "Usage: $0 filename" >&2
exit 1
fi
cp "/script/test/123/$1" /etc/hosts/ |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks for correcting me
![]() |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Connect Oracle using shell script at run time | kritibalu | Shell Programming and Scripting | 4 | 07-07-2011 03:18 PM |
| Run a script when a file is modified/time stamp changed | aemunathan | Shell Programming and Scripting | 3 | 04-23-2011 03:55 AM |
| Shell script to find the run time based on log entries? | mailtopranesh | Shell Programming and Scripting | 1 | 10-31-2010 07:25 PM |
| Generate array name at run time Korn shell | harris2107 | Shell Programming and Scripting | 2 | 05-04-2010 10:36 AM |
| How to run this program with only one input file at a time | Prat007 | Shell Programming and Scripting | 2 | 01-10-2009 03:27 PM |
|
|