LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-30-2005, 01:19 AM   #1
topcat
Member
 
Registered: Feb 2003
Distribution: ubuntu 6.06, ubuntu 7.04 AMD 64bit, 7.10 AMD 64bit
Posts: 62

Rep: Reputation: 15
find replace via html form


I am trying to create a form, that will accept 3 values.

The path. $PATH (including / etc characters)
The Searched Value ($VALUE)
the new Value ($NEW_VALUE)

It should go recursively into all files in the entered path and do a search and replace.

I believe we can do a shell script with SED. Though how do we do it recursively and only for the entered path?
Also, what needs to be done for it to run via php and a html form?

Is it possible to have some kind of a report which says, ok, this many entries found and replaced?

Is this the right way to start?

"sed -e 's|old string|new/better string|g'

thanks!
tc
 
Old 07-31-2005, 11:05 AM   #2
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
You could probably do the whole thing in PHP using preg_replace(). You can use find to return a list of suitable file names from a given start point
Code:
find startdir -type -f -print
Perl is another program to consider using as that makes changing files in situ a breeze
Code:
perl -pi.bak -e 's|old string|new/better string|g'  file1 file2 ...
will make the changes to the files, preserving the originals with a .bak suffix.

There's More Than One Way To Do It!
 
Old 08-02-2005, 06:13 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
how i do it:
create a shell script to do what you want.
run it from a CGI form.

I have a simple template CGI that will run
any shell command. So now i just plug a differet shell script
in for anything that crops up. (as long as it's not too interactive)

also, if you pass parameters, do them like:
command var=value var2=this
then you can read them in, pass them to 'eval'
and hey presto, instant ready variables.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Html Form File Cottsay General 0 11-05-2005 01:30 PM
html question: form henrikanttonen Programming 4 08-13-2004 07:28 AM
Contact form on HTML Gerardoj Linux - General 1 03-26-2004 02:08 AM
an html form question matt_w_lambert Programming 3 10-30-2003 11:41 PM
problem with html form meluser Linux - Software 4 03-15-2003 12:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration