Programming :: Bash Script For Finding And Replacement In Any Webpage Code?

Feb 19, 2011

I want to write Bourne-shell script that will be to do finding and replacement in any web page code (.htm file) name of the tied folder in which have been saved pictures, .css, .js and other files. This folder create a web browser when we save web page completely and has so name as web page and has ending '_files'. I have many web pages where name of their folder are incorrect. Of course, my web browser shows these web pages without pictures. I can count amount of web pages in a folder (/path) needed for me.

1) find /path -type f -name "*.htm*" -print | grep -c .htm or find /path -type f -name *.htm | wc -l I can get list of web pages.

2) ls /path *.htm > out-list But I don't know how to assign the value from out-list (2) or result commands from pipeline (1) to a variable. Then I want to do next:

3)

var="1"
# where variable 'list' is an amount of web pages
while [ $var -le $list ]

[code]....

4)assign the 1st (then 2nd , etc. ) value from out-list (2) to variable 'webfile'
sed -n $var,+0p out-spisok

5)find the 1st string value '_files' in the 'webfile' grep -m1 _files $webfile

6)For example, 'abracadabra_files' is an incorrect folder in the 'webfile' I must to know start and end position 'abracadabra' without ending '_files', "cut" name of the incorrect folder and assign it to the variable 'finder' finder = 'abracadabra' BTW, name of a folder before '_files' is between '="' and '_files' in any web page code.

7)foldernew = $webfile (without '.htm')' foldernew' is equal with name of the tied folder without ending '_files' in the folder '/path'

8)find and replace in the 'webfile' and save result in the 'webfile-out'sed s/$finder/$foldernew/g $webfile > $webfile-out

View 5 Replies


ADVERTISEMENT

Programming :: Nontrivial String Replacement With Bash On-board Means?

Jan 9, 2011

My simple bash-script replaces --> by the HTML-entity for the right arrow. To be precise, it replaces --*> by → Until now, I used sed, for example:

Code: $ flight='AMS --> JFK'
$ echo "$flight" | sed -e 's/ --*> / → /g'

AMS → JFK With sed, -* matches zero or more dashes, because for sed the * is the Kleene Star matching zero or more instances of the previous element. So with sed, --*> matches exactly what I want:

Code:

->
-->
--->
---->

Because sed seems oversized for that task, I played around to accomplish the same with on-board means of bash without using sed. On first thought, this line looks like doing the same but it isn't:

Code: $ flight='AMS --> JFK'
$ echo "${flight// --*> / → }"

AMS → JFK As I recently learnt in this forum, this * isn't the Kleene Star. It is a multi-character wildcard matching any zero or more consecutive characters. So here, --*> matches:

Code:

->
-->
--->
---->
-<>
->>

-abc> And if you continue your flight to SEA, then the result is totally wrong because the * matches greedily:

Code: $ flight='AMS --> JFK --> SEA' $ echo "${flight// --*> / → }" AMS → SEA

The sed line above would produce the correct result and would match the dashes correctly.

View 3 Replies View Related

Programming :: Finding A Code For Network Adapter Information?

Nov 13, 2009

I want to get the hardware information in linux. As in windows we can have API to get the network adapter information and all. But in linux why dont we have? i try to read network adapter info in /proc/bus/devices file.. but that file is very hard to parse.and i looked at the lspci source c ode. but unfortunately I dint undersatnd that code to get the network adapter information.

View 1 Replies View Related

Programming :: Java Code To Implement "wget" To Save A Webpage

Feb 24, 2010

This is the code i used, there is no error in execution but no file is bein saved in the working directory. I'm new in java,so just started learning.

public class Hel
{
public static void main(String args[])
throws IOException

[code]....

View 5 Replies View Related

Programming :: Finding The Tcl Code For Cognitive Wireless Network Scene

May 24, 2011

finding a tcl code for cognitive wireless network scene

View 4 Replies View Related

Programming :: Finding A Partition Type Reader Script / Code?

Aug 6, 2010

I was wondering if there is anyone who has some kind of a small script/code (preferably in C/C++) which reads a partition and just displays the type. For example, the script/code would be called partype and should be something like this: partype /dev/sda1, will read sda1 and display for example ext4, because sda1 was formated as ext4.

Note: I'm not a developer so I have no idea how this should be done, plus I would like the script/code to do it by itself the checking, without using fdisk/sfdisk/cfdisk/parted/gparted, because none of this apps work quite well when it comes to the partition type or file system type.

View 13 Replies View Related

Programming :: How To Use Bash Variable In C Code?

Feb 16, 2011

I want to write a c program with some shell scripts.Now For a simple C program. I am Setting a variable called val2 in bash, now I want to use bash variable val2 in C code. How do I do that?The above doesn't work (coz its spawning a different memory space and when shell script ends the variable dies with it as per my research but how do I keep them in same memory space)Also Is there any Good reference where they teach how to integrate C and Bash Together?

View 5 Replies View Related

Programming :: Any Benefit To Code In KSH Or ZSH Instead Of Bash?

Jun 15, 2010

I have been scripting (or programming) in Bash shell for around 2+ years now. I have heard that ksh and zsh are better shells than bash. Are there any differences on the scripting side too, I mean is it easier to write a script in ksh or zsh rather than bash? Is there any benefit to code in ksh or zsh instead of bash.

View 1 Replies View Related

Programming :: Passing Parameters From C Code To Bash Script

Apr 16, 2011

I get no print to stdout on screen from the C code.Does bash somehow block or mask it?I get print from bash. I get this error in the non-test bash script like: let "rdval = $rdstr"syntax error: operand expected (error token is " ")The let command prints rdval= but I presume this is due to the printf test statements getting in the way.I am getting no compile errors. Why does the C code not print the values specified?

View 2 Replies View Related

Fedora :: Finding A Replacement Network Device Manager?

Jun 15, 2011

finding a replacement network device manager?

View 7 Replies View Related

Debian Programming :: How To Do Code Bash Script To Run Su And Enter Password

Sep 15, 2014

Whats the bash script for like, how synaptic package manager runs ..

When you run synaptic it ask for root password ..

How do I do this in bash script?

View 5 Replies View Related

Programming :: Can Bash Commands Be Converted To Assembly Like C Source Code?

Nov 30, 2010

I have read where C is first converted to Assembly before its final compilation to binary. Is there a way to do this with Bash commands? I would like the understanding that Assembly allows to Bash somehow.

View 14 Replies View Related

Programming :: Kill Follow-on Code If Source Fails In Bash?

Dec 20, 2009

I have a Bash script that runs other bash scripts. If the parent code fails, is there any way for me to also kill the child code?That kills any multiple instances of a script if I run it more than once. Is there any way I can just modify this into something that prevents the child code from running/continuing from running if the parent stops from an error?

View 3 Replies View Related

Programming :: Bash-code To Rename Files Based On Config File

Apr 12, 2010

I'm writing a bash shell script that among various other things will traverse through a directory with hundreds of files and rename those who match a pattern found in a config file. It's expected that only about one in ten files will actually match, and those who don't, will simply just be ignored for this purpose.

This should for instance cause the file "dBase program file December 1987.prg" to be renamed "Clipper source code December 1987.prg", and conversely "C++ source August 1996.cpp" to be renamed "C source code August 1996.cpp" etc.A sample file such as "Random Data File.dat" should not be renamed here since it's not mentioned in the config file..What is the quickest, most elegant way to do this in bash?I am thinking of using bash's built-in regex matching combined with the /bin/rename utility, but don't quite know how to get started to catch this..I guess there are plenty ways of doing this in perl and elsewhere as well, but since this has to integrate into a pre-existing bash script, that's what I'm looking for.Anyone out there with a spare moment to offer a hint in the right direction?

View 14 Replies View Related

Programming :: Change A Line In A File Code - Sed Special Characters Bash Script

Jan 26, 2011

I'm having issue when trying to change a line in a file

[Code]....

View 1 Replies View Related

Software :: Timesnapper Alternative \program For Windows, Having A Hard Time Finding A Replacement?

Sep 8, 2010

Wondering if anyone knows of a "Timesnapper" alternative. Love this program for windows, having a hard time finding a replacement.

View 4 Replies View Related

Ubuntu Multimedia :: Finding A Slideshow Maker For A Webpage?

Feb 24, 2011

recommend a good slideshow maker that'll make great slide shows to be used on a web page?I need a slideshow maker that resides on my computer and not a web based one.

View 8 Replies View Related

Ubuntu Multimedia :: Saving An Mp3 File From A Webpage's Xml Source Code?

Sep 1, 2010

I listen to a radio show that broadcasts online a lot named ChatterBox Video Game Radio, and when i e-mailed one of the hosts about retrieving archived shows since the site didn't have any archiving of old shows or a link to it. Alon was nice enough to send me one of their old web pages with a HUGE list of archives but it's only the xml source code of the page. since the page isn't live of course, and because of the how he had to send me the code for the page and not a hyperlink to the page, i have the source code. now going through the source code of the page he emailed to me, i can find links to .mp3 files and i can open them and listen to the shows in web browsers, but i was hoping to save them to my computer forfuturelistening.URL]ww.chatterbox'ssite.com/whatever/anotherfolder/showiwanttosave.mp3 in firefox quicktime comes in and lets me listen (as long as my internet connection is active) but wont enable me to save because i dont have the pro version of quicktime. quicktime is good, but i dont use it enough to actually buy the product, and i'm not going to buy the product for just a one time use. is there another way to where i can save this file using the address from the source code (and the ChatterBox allows listeners to save their shows to computer for free, so it not some work around to rob them of money. i fully support them) without having to buy quicktime 7 pro(a product i never really use)?

View 4 Replies View Related

Programming :: Bash Code To Prevent Redundantly Including Files, Like Php's "include_once"?

Jul 13, 2010

I wrote some bash code to prevent redundantly including files, like php's "include_once". I've simplified it here so don't worry that it appears not to do anything:

Code: alias .='Include'
alias source='Include'
export __INC__functions=1

[code]....

View 1 Replies View Related

Programming :: Go: A Cd/pushd/popd/dirs Replacement?

May 17, 2011

I have to use the older ksh on SUN and AIX alot...and kinda missed the pushd concept for jumping around a bunch of directories.but not really, because I didnt always want to pop off my directory, just wanted to cd there.So I wrote a ksh or bash friendly script with usage as below.Make it available by sourcing: . godir.sh

Code:
# Script: godir
# Written: 05-16-11 13:49:17 By: AWJurgensen

[code]....

View 1 Replies View Related

Programming :: Selenium Java Code Into Equivalent Php Code?

Mar 30, 2011

I need to rewrite the selenium java code into its equivalent php code.

View 5 Replies View Related

General :: Finding The Kernel Source Code?

Apr 14, 2011

where can i find linux kernel source code?

View 4 Replies View Related

Ubuntu :: USB Over Ethernet - Finding Source Code In Package?

Jun 23, 2010

First of all, I am pretty new to linux and I have 2 install a USB OVer IP software. I downloaded the software for UBUNTU n I really do not know where to find the installer. I want to find the source code in the package too.. its an open source project. So I believe the source codes are included in that .

View 5 Replies View Related

Programming :: Write A Replacement For Shell Command Line Interpreter?

Sep 2, 2010

If say, I want to read the input given by user at the command prompt and write a code to execute the cmd given then which commands do i use to implement this ( Im writing the code in C )?

View 8 Replies View Related

Networking :: Finding A Network Simulator Code In C++ And Perl Not Using Tcl Or Otcl?

Apr 19, 2011

I need to refer a sample code to develop a network simulator using c++/system c as back end and perl scripting asd front end.CAn anyone please refer to me any websites were this kind code is given.I do not want to use this otcl script language so wothout this is any code available just for sample so i wii know were to start and develop my own code.

View 3 Replies View Related

Programming :: How To Stream Webpage

Sep 30, 2010

I need to stream a webpage to my application and i tried something like this but i get segmentation faults. Is there any example in c and/or gtk that i can peek on.

View 2 Replies View Related

Programming :: Cannot Extract Webpage For Processing

Aug 25, 2010

I am trying to extract a web page via Google for processing. I am able to create a proper query and test it using cut/paste into the address bar of my firefox browser.

When I attempt to extract the page with wget:
wget -O - -q "$query"
I do not see the information that is present when I used the browser.

View 2 Replies View Related

Programming :: Do A Popup Window On A Webpage?

Mar 2, 2010

I want to do a "gallery" on a webpage, ie. a series of thumbnails, whhich when clicked, will popup a new window of a bigger image of that same things (with more details about it, etc.). How do I do that? (I think it's soemthing to with "window.popup" in Javascript, but how do I use that? Can I do it with <a href="something" target=new>?)

View 12 Replies View Related

Programming :: Download A Webpage Using QtNetwork?

Jun 22, 2010

How to download a web page using QtNetwork? I then plan on extracting data from it with QRegExp.

View 11 Replies View Related

Programming :: Upload .cgi File To Webpage?

Apr 21, 2011

The software Nagios uses .cgi files to show a lot of things.. services, hosts, etc etc. Is there any way to pick up those .cgi files and import them to other web page? how to do it?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved