Jump to content

Is there a website with a string replacement web script?

TigerBoy

Hi Guys,

 

 

Good day!

 

I am searching for a website/page that can run a online application/script similar to this:

 

1) I have a list of strings that are differentiated by a new line (one string = one line)

2) I want that each line of string to replace a variable, "variableHere" in a block of text similar to below:

config somethingedit 1config somethingelseedit "variableHere"config somethingmorenextendconfig somethingedit 2config somethingelseedit "variableHere"config somethingmorenextend

3) I want this to loop per string so if I have a list of 100 strings, I can have 200(100) blocks of these commands

4) An example is the following:

List of Strings:192.168.1.1192.168.1.2Output:config somethingedit 1config somethingelseedit "192.168.1.1"config somethingmorenextendconfig somethingedit 2config somethingelseedit "192.168.1.1"config somethingmorenextendconfig somethingedit 1config somethingelseedit "192.168.1.2"config somethingmorenextendconfig somethingedit 2config somethingelseedit "192.168.1.2"config somethingmorenextend
 
 
I can actually just code a script like this, though I am unable to bring in any script, executable, batch files, and the like to the environment I will access this website through. This is for running so many commands through a vendor device and it is such a drag (not to mention it is giving strain on my wrist copy pasting....)
 
 
Do you guys have any recommendations? I can reduce my work time by 95% if I can find a website with a script like this.
 
 
 
Thanks for the further help on this!
Link to comment
Share on other sites

Link to post
Share on other sites

snip

 

Ha, I could do this with python... I think.

As in put your input into a textfile then have it output what you want onto another text file.

Im learning it at uni so I just find it interesting seeing a a problem  I could solve with what ive learnt so far.

As for making it web based, I wouldn't have a bloody clue sorry

Link to comment
Share on other sites

Link to post
Share on other sites

Hi Guys,

 

 

Good day!

 

I am searching for a website/page that can run a online application/script similar to this:

 

1) I have a list of strings that are differentiated by a new line (one string = one line)

2) I want that each line of string to replace a variable, "variableHere" in a block of text similar to below:

config somethingedit 1config somethingelseedit "variableHere"config somethingmorenextendconfig somethingedit 2config somethingelseedit "variableHere"config somethingmorenextend
3) I want this to loop per string so if I have a list of 100 strings, I can have 200(100) blocks of these commands

4) An example is the following:

List of Strings:192.168.1.1192.168.1.2Output:config somethingedit 1config somethingelseedit "192.168.1.1"config somethingmorenextendconfig somethingedit 2config somethingelseedit "192.168.1.1"config somethingmorenextendconfig somethingedit 1config somethingelseedit "192.168.1.2"config somethingmorenextendconfig somethingedit 2config somethingelseedit "192.168.1.2"config somethingmorenextend
 

 

I can actually just code a script like this, though I am unable to bring in any script, executable, batch files, and the like to the environment I will access this website through. This is for running so many commands through a vendor device and it is such a drag (not to mention it is giving strain on my wrist copy pasting....)

 

 

Do you guys have any recommendations? I can reduce my work time by 95% if I can find a website with a script like this.

 

 

 

Thanks for the further help on this!

 

 

Ha, I could do this with python... I think.

As in put your input into a textfile then have it output what you want onto another text file.

Im learning it at uni so I just find it interesting seeing a a problem  I could solve with what ive learnt so far.

As for making it web based, I wouldn't have a bloody clue sorry

 

 

Yup, python could be able to do this. Input the ip and output the full text.

 

 import sys;print("config something" + "\n" +"edit 1"+ "\n" +"config somethingelse"+ "\n" +"edit {}".format(sys.argv[1])+ "\n" +"config somethingmore"+ "\n" +"next"+"\n" +"end"+"\n" +"config something"+"\n" +"edit 2"+"\n" +"config somethingelse"+"\n" +"edit {}".format(sys.argv[1])+"\n" +"config somethingmore"+"\n" +"next"+"\n" +"end")

Just pass the variable to the script and you're good.

Eg (on command line):

python scriptname variableHere

That time I saved Linus' WiFi pass from appearing on YouTube: 

A sudden Linus re-appears : http://linustechtips.com/main/topic/390793-important-dailymotion-account-still-active/

Link to comment
Share on other sites

Link to post
Share on other sites

Yeah, I wish I can do it, I am in such a controlled environment where if I try running .py(or anything that is not in their white list) they would take my machine and do a bit-wipe and I would get in deep trouble.

 

The monitoring is strict and the only way I can get pass it is to have the script run on a web hosted environment(Java is available in my machine though I can only run it via web page/utility if it pulled from an online source rather than local). As of the moment I cannot run anything on my machine except my vendor access tools, some documentation tools (office), and a browser.

Link to comment
Share on other sites

Link to post
Share on other sites

Yeah, I wish I can do it, I am in such a controlled environment where if I try running .py(or anything that is not in their white list) they would take my machine and do a bit-wipe and I would get in deep trouble.

 

The monitoring is strict and the only way I can get pass it is to have the script run on a web hosted environment(Java is available in my machine though but I can only run off it web based if it pulled from an online source rather than local). As of the moment I cannot run anything on my machine except my vendor access tools, some documentation tools (office), and a browser.

Well I have actually have a completely unused domain and I decided to write up the code for you, if you know how to make Python run like that let me know and ill try work it out for you

def get_input_file():input_str = open("input.txt", "r")contents = input_str.read()contents = contents.split("\n")input_str.close()return contentsdef output_file(input_list):output_file = open("output.txt", "w")for i in input_list:output_file.write("config something \nedit 1 \nconfig somethingelse \nedit " + i + " \nconfig somethingmore \nnext \nend \nconfig something \nedit 2 \nconfig somethingelse \nedit " + i + " \nconfig somethingmore \nnext \nend\n")output_file.close()returndef main():input_list = get_input_file()output_file(input_list)
Link to comment
Share on other sites

Link to post
Share on other sites

Hi, so I was bored... http://pastebin.com/x1h4p3ATYou can save as index.html (The code), and then I think is mostly intuitive but in your example, the code would be at "Where to replace", variables list at "Variables" and the word to replace in "Variables" Then just need to click the button.

 

Hope it works :)

I'm from Spain so English is not my main language but I'm trying to make my best not writing any typo.

Link to comment
Share on other sites

Link to post
Share on other sites

Well here you go dude

http://toxicpc.com/

The code from the above guy is uploaded onto that website

let us know if that's helpful or not

Wow, thanks a lot for this. Though I was really thinking of a button that will just loop the list every time it is clicked and display the whole block of "Where to replace" that was looped. (So I can just copy paste the whole block in the CLI of my device every time).

 

I was also thinking of a permanent solution where someone else has this available for quite a while since I have to do this job for more than a year at least and I don't want to burden you with keeping this website up under your registered domain.

 

Thinking of discussing this with my colleagues if they want to chip in a 1$ monthly so we could get our own web hosted domain, then we would place all our scripts there and our life could be easier though I don't think they would agree.

Link to comment
Share on other sites

Link to post
Share on other sites

Wow, thanks a lot for this. Though I was really thinking of a button that will just loop the list every time it is clicked and display the whole block of "Where to replace" that was looped. (So I can just copy paste the whole block in the CLI of my device every time).

 

I was also thinking of a permanent solution where someone else has this available for quite a while since I have to do this job for more than a year at least and I don't want to burden you with keeping this website up under your registered domain.

 

Thinking of discussing this with my colleagues if they want to chip in a 1$ monthly so we could get our own web hosted domain, then we would place all our scripts there and our life could be easier though I don't think they would agree.

 

Well i'd be happy to make that for you but again I have no idea how to make that happen, I dont even know how that other one works lol. But like I said that domain is unused and paid for until about September I think so feel free to message me if you want a different script to run on it.

However it would probably be a good idea to have a domain for everyone to use. It still seems a bit silly to me that you aren't allowed to run scripts like this which would increase your productivity on your local machines.

Link to comment
Share on other sites

Link to post
Share on other sites

Wow, thanks a lot for this. Though I was really thinking of a button that will just loop the list every time it is clicked and display the whole block of "Where to replace" that was looped. (So I can just copy paste the whole block in the CLI of my device every time).

 

I was also thinking of a permanent solution where someone else has this available for quite a while since I have to do this job for more than a year at least and I don't want to burden you with keeping this website up under your registered domain.

 

Thinking of discussing this with my colleagues if they want to chip in a 1$ monthly so we could get our own web hosted domain, then we would place all our scripts there and our life could be easier though I don't think they would agree.

 

That would be a real waste of money.

 

First of, there are countless free hosting offers available on the net, some examples are:

http://www.square7.ch/?lang=en

https://5gbfree.com/

https://www.bplaced.net/?lang=en

 

And countless more. They are all more than enough for what you want to do.

 

 

The other (and in my opinion better) solution would be to simply write a script in any scripting language like python or php and use one of the countless online sandboxes to run your code.

Example: Copy this code

$values = array(//Put all your values here like this"192.168.0.1","192.168.0.2","192.168.0.3",);//Put your desired text here, "variableHere" will be replaced$text = <<<'EOT'config somethingedit 1config somethingelseedit "variableHere"config somethingmorenextendconfig somethingedit 2config somethingelseedit "variableHere"config somethingmorenextendEOT;    foreach( $values as $v ){    echo str_replace('variableHere', $v, $text);}

Go to one of these pages:

http://sandbox.onlinephpfunctions.com/

http://phpfiddle.org/

(Or just google "run php code online"....)

 

Paste the code there and run it. That way you only need to have the template somewhere on your hdd or on the net and are much more flexible since you can always modify it if you need to.

Link to comment
Share on other sites

Link to post
Share on other sites

Well i'd be happy to make that for you but again I have no idea how to make that happen, I dont even know how that other one works lol. But like I said that domain is unused and paid for until about September I think so feel free to message me if you want a different script to run on it.

However it would probably be a good idea to have a domain for everyone to use. It still seems a bit silly to me that you aren't allowed to run scripts like this which would increase your productivity on your local machines.

 

 

I totally agree, though it is actually a digital security environment so yeah, kind of understandable. I am actually thinking of using sandboxing for now until they reconsider on making a nice tool or allowing us to do so. This actually did not pass through my mind (recommended by cynexit). 

 

I would like to kindly request if you may modify the button to loop the whole content of the list then display it on the textbox below if you are available to do so.

 

You can bring the page down a day after if you want, and really, thank you for all the help, I never knew people would be as cool as you lending a domain even if it is unused.

 

I hope you have a very great year ahead. :)

 

 

That would be a real waste of money.

 

First of, there are countless free hosting offers available on the net, some examples are:

http://www.square7.ch/?lang=en

https://5gbfree.com/

https://www.bplaced.net/?lang=en

 

And countless more. They are all more than enough for what you want to do.

 

 

The other (and in my opinion better) solution would be to simply write a script in any scripting language like python or php and use one of the countless online sandboxes to run your code.

Example: Copy this code

$values = array(//Put all your values here like this"192.168.0.1","192.168.0.2","192.168.0.3",);//Put your desired text here, "variableHere" will be replaced$text = <<<'EOT'config somethingedit 1config somethingelseedit "variableHere"config somethingmorenextendconfig somethingedit 2config somethingelseedit "variableHere"config somethingmorenextendEOT;    foreach( $values as $v ){    echo str_replace('variableHere', $v, $text);}

Go to one of these pages:

http://sandbox.onlinephpfunctions.com/

http://phpfiddle.org/

(Or just google "run php code online"....)

 

Paste the code there and run it. That way you only need to have the template somewhere on your hdd or on the net and are much more flexible since you can always modify it if you need to.

 

 

I never considered sandboxing, thanks a lot. I will try making it with my own native languages since I really am terrible with web scripting. 

 

thank you very much and you have a great day ahead.

Link to comment
Share on other sites

Link to post
Share on other sites

I totally agree, though it is actually a digital security environment so yeah, kind of understandable. I am actually thinking of using sandboxing for now until they reconsider on making a nice tool or allowing us to do so. This actually did not pass through my mind (recommended by cynexit). 

 

I would like to kindly request if you may modify the button to loop the whole content of the list then display it on the textbox below if you are available to do so.

 

You can bring the page down a day after if you want, and really, thank you for all the help, I never knew people would be as cool as you lending a domain even if it is unused.

 

I hope you have a very great year ahead. :)

 

 

 

 

I never considered sandboxing, thanks a lot. I will try making it with my own native languages since I really am terrible with web scripting. 

 

thank you very much and you have a great day ahead.

 

Here is the modified Script to do so, he can upload: http://pastebin.com/SwrGE7h4

 

Hope it works!

I'm from Spain so English is not my main language but I'm trying to make my best not writing any typo.

Link to comment
Share on other sites

Link to post
Share on other sites

You can also literally run sed or replace (*nix) to do this.

--Neil Hanlon

Operations Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×