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
Defining EDITOR Variable - Tru64 Bagel08 UNIX for Dummies Questions & Answers 2 12-15-2008 12:05 PM
defining a printer in qconfig matheeq AIX 0 03-18-2008 11:55 AM
Defining Variables sailorliones UNIX for Dummies Questions & Answers 4 07-21-2006 04:09 PM
defining a variable as a number or character? noobian UNIX for Dummies Questions & Answers 1 04-26-2005 09:19 PM
Defining variables at boot time ianf UNIX for Dummies Questions & Answers 7 01-07-2002 01:03 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 01-04-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
Is the start of the script trying to rename both the files named in shell variables ${DMI_FILE} and ${SNMP_FILE} , rather than a file called "conf" in the current working directory ?
If so, then please try the construct below (untested) and remove the "echo" from the "mv" line if it does what you want. I've avoided having a shell variable called "conf" because it appears to be causing confusion! Where you had a shell variable called "conf" I have called it "filename". We are back to "bash" because I don't think that "test -e" is valid in ksh.

Code:
#!/usr/bin/bash

# My Variables
DMI_FILE="/etc/dmi/conf"
SNMP_FILE="/etc/snmp/conf"

for filename in "${DMI_FILE}" "${SNMP_FILE}"
do
        if [ -e "${filename}" ]
        then
                echo mv "${filename}" "${filename}.orig"
                echo "${filename} has been moved"
        else
                echo "${filename} does not exist"
                exit
        fi
done
  #2 (permalink)  
Old 01-04-2009
em23's Avatar
em23 em23 is offline
Registered User
  
 

Join Date: May 2008
Location: Chicago
Posts: 31
here is the error that i get when i run the script.

mv: cannot access conf
mv: cannot access conf
  #3 (permalink)  
Old 01-04-2009
em23's Avatar
em23 em23 is offline
Registered User
  
 

Join Date: May 2008
Location: Chicago
Posts: 31
so would the mv statement be written into this like so...

Code:
if [ -d /etc/dmi/conf/ ];
then
   print '/etc/dmi/conf/ does exist'
do
   mv "$?" conf.orig
else
   print '/etc/dmi/conf/ does NOT exist'
fi
  #4 (permalink)  
Old 01-04-2009
em23's Avatar
em23 em23 is offline
Registered User
  
 

Join Date: May 2008
Location: Chicago
Posts: 31
nevermind. disregard my last. my test showed an error in the 'do' line.
  #5 (permalink)  
Old 01-04-2009
em23's Avatar
em23 em23 is offline
Registered User
  
 

Join Date: May 2008
Location: Chicago
Posts: 31
looks like that did the trick, methyl.

thank you both for your feedback and suggestions.
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 04:33 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