Sponsored Content
Top Forums Shell Programming and Scripting question about sed and other stuff Post 94564 by vbslim on Saturday 31st of December 2005 11:23:14 PM
Old 01-01-2006
I seem to be running in circles any help would be nice

Code:
bash$rootftp on

Code:
#!/bin/bash -x

#work directory
wdir="/home/web_users/test"

#temp directory
tmpd="tmp"

#original file
file="myfile"

word="RootLogin off"

word2="RootLogin on"

#temp file
tfile="myfile1.txt"

  on=1
 off=1
   if [ $on = 1 ]; then
        cp $wdir/$file $tmpd
        sleep 1
        sed -e \"s/$word/$word2/\" $file > $tmpd/$tfile
        sleep 1
        mv -f $tmpd/$tfile $wdir/$file
        ## clean the tmp dir
        rm -f $tmpd/$file


    elif [ $on = no ]; then
         cp $wdir/$file $tmpd
         sleep 1
          sed -e \"s/$word2/$word/\" $file > $tmpd/$tfile
         sleep 1
         mv -f $tmpd/$tfile $wdir/$file
         ## clean the tmp dir
         rm -f $tmpd/$file


     else
      echo "you must enter either on or off"
   fi
 done

results in this
Code:
-bash-2.05b$ ./on on
+ wdir=/home/httpd/web_users/test
+ tmpd=/home/httpd/web_users/test/tmp
+ file=myfile
+ word=RootLogin off
+ word2=RootLogin on
+ tfile=myfile1.txt
+ on=1
+ '[' 1 = 1 ']'
+ cp /home/httpd/web_users/test/myfile tmp
+ sleep 1
+ sed -e '"s/RootLogin' off/RootLogin 'on/"' myfile
sed: -e expression #1, char 1: Unknown command: `"'
+ sleep 1
+ mv -f /home/httpd/web_users/test/tmp/myfile1.txt /home/web_users/test/myfile
+ rm -f /home/httpd/web_users/test/tmp/myfile

 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Simple stuff.

I hacked my TIVO a few months ago. I made a computer specifically for this, but I only used a UNIX boot disk to get all the TIVO goodies to work. I am intersted in getting some version of UNIX on this machine and getting it onto my network. I only want to do some simple file transfers, maybe... (1 Reply)
Discussion started by: IamJAWA
1 Replies

2. Windows & DOS: Issues & Discussions

weird stuff

I coudln't think of another topic to post this under as the OS on the system is XP pro. Ok here is the go. I'm upgrdaing a mates computer. A AMD 1200Mhz and well it wouldn't boot from the CD to do a fresh install (By upgrade I mean OS with complete new install). So I opened up the box and... (4 Replies)
Discussion started by: woofie
4 Replies

3. Shell Programming and Scripting

Sed Question 1. (Don't quite know how to use sed! Thanks)

Write a sed script to extract the year, rank, and stock for the most recent 10 years available in the file top10_mktval.csv, and output in the following format: ------------------------------ YEAR |RANK| STOCK ------------------------------ 2007 | 1 | Exxon... (1 Reply)
Discussion started by: beibeiatNY
1 Replies

4. Shell Programming and Scripting

Please help with monitoring stuff

Hi, I am trying to write a script to do monitoring kind of stuff, requirement - when a server is given a start it updates a file called server.log, I need to keep on grepping the word "Running" and as soon as it comes , script should be exited with the message , "Server came up... (2 Replies)
Discussion started by: sunilmenhdiratt
2 Replies

5. Shell Programming and Scripting

awk stuff

Hi, My input file data will be |ABCD|EFGH|IJKL|MNOP |ABCD|EF\|GH|IJKL|MNOP I am expecting output , |"ABCD"|"EFGH"|"IJKL"|"MNOP" |"ABCD"|"EF|GH"|"IJKL"|"MNOP" Note : The change basically the pipe deilmited file does contain | as value for some of the column but | will come with... (8 Replies)
Discussion started by: Nandy
8 Replies

6. Programming

More Arduino Stuff...

HI all... (Apologies for any typos.) To add to Neo's Arduino subject matter I have decided to upload this in ".zip" format. Ignore "*.info" files these are AMIGA icons only and also the "HAM" drawer as these are photos in ancient AMIGA HAM modes. I have noticed that there are current... (6 Replies)
Discussion started by: wisecracker
6 Replies
ftp::geturl(n)							    ftp client							    ftp::geturl(n)

__________________________________________________________________________________________________________________________________________________

NAME
ftp::geturl - Uri handler for ftp urls SYNOPSIS
package require Tcl 8.2 package require ftp::geturl ?0.2.1? ::ftp::geturl url _________________________________________________________________ DESCRIPTION
This package provides a command which wraps around the client side of the ftp protocol provided by package ftp to allow the retrieval of urls using the ftp schema. API
::ftp::geturl url This command can be used by the generic command ::uri::geturl (See package uri) to retrieve the contents of ftp urls. Internally it uses the commands of the package ftp to fulfill the request. The contents of a ftp url are defined as follows: file The contents of the specified file itself. directory A listing of the contents of the directory in key value notation where the file name is the key and its attributes the asso- ciated value. link The attributes of the link, including the path it refers to. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category ftp of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
ftpd, mime, pop3, smtp KEYWORDS
ftp, internet, net, rfc 959 ftp 0.2.1 ftp::geturl(n)
All times are GMT -4. The time now is 10:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy