Copy text from web page and add to file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy text from web page and add to file
# 1  
Old 03-22-2016
Copy text from web page and add to file

I need help to make a script for Ubuntu to OSCam that copy the text on this website that only contains "C: ip port randomUSERNAME password" and want to exclude the text "C:" and replace the rest with the old in my test.server file.

Code:
(line 22) device   = ip,port  
(line 23) user     = randomUSERNAME  
(line 24) password = password

the file location is /usr/local/etc/test.server. Please help someone! Regards

Last edited by jim mcnamara; 03-22-2016 at 11:23 PM..
# 2  
Old 03-23-2016
Not clear. Any attempts/ideas/thoughts from your side?
# 3  
Old 03-23-2016
If the file is in your /usr/local, why do you need IP address and port? If this refers to a file system on a different host, have a look at the commands **rcp** and **scp**. They are usually used for transferring files between different hosts.
# 4  
Old 03-23-2016
Don't know if I shall use wget or curl to just copy that text from the website. Can't be that hard because it's just a blank page with that text. And then divide up all (spaces) and store them into variables. Then erase the right line and add like device = StoredVariableA.. Don't know if it's possible in scripting from terminal.

---------- Post updated at 03:25 AM ---------- Previous update was at 03:24 AM ----------

I copy and paste the new information from that website and paste it into my config and I need to do it daily.
# 5  
Old 03-23-2016
Sure it is possible, but from your posting, it is unclear, at which steps of this process you have questions. You should be more precise. If there is more than one issue, it is possible to create several threads instead of lumping everything into one question.
# 6  
Old 03-23-2016
I have figured out how to remove C: from the text so I have now "randomIP randomPORT randomUSERNAME randomPASSWORD" but how to assign each one to a variable, like var1, var2, var3 and var4? The separator should be (space) ?

---------- Post updated at 11:33 AM ---------- Previous update was at 10:06 AM ----------

I fixed the script now.. Thanks anyways!
# 7  
Old 03-24-2016
You need to be more precise, on what you have and what you want.

Is it correct, that you have in a shell variable a string consisting of words separated by spaces, and you want to assign the words to individual shell variables?

For which shell should the solution work?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Converting text file to html page

Hello Everyone, I have the following text file with the each field separated by newline Text file P file1-en-us_US-20170718T150157Z.json Wed 19 Jul 2017 06:10:13 AM EDT P file2-en-us_US-20170718T160150Z.json Wed 19 Jul 2017 06:10:13 AM EDT P file3-en-us_US-20170718T163218Z.json Wed... (9 Replies)
Discussion started by: nextStep
9 Replies

2. Shell Programming and Scripting

Web page with picture, text, php function

Hello. I'm trying to create a web page which the presentation is as follows: 1 °) at the top of page an image 2 °) below the text 3 °) to complete a php function that returns information. I tried different things but none work. Script 1: <!DOCTYPE html> <html> <head> <style> div { ... (5 Replies)
Discussion started by: jcdole
5 Replies

3. Shell Programming and Scripting

Use curl to send a static xml file using url encoding to a web page using pos

Hi I am try to use curl to send a static xml file using url encoding to a web page using post. This has to go through a particular port on our firewall as well. This is my first exposure to curl and am not having much success, so any help you can supply, or point me in the right direction would be... (1 Reply)
Discussion started by: Paul Walker
1 Replies

4. Shell Programming and Scripting

Grep text matching problem with script which checks if web page contains text.

I wrote a Bash script which checks to see if a text string exists on a web page and then sends me an email if it does (or does not e.g. "Out of stock"). I run it from my crontab, it's quite handy from time to time and I've been using it for a few years now. The script uses wget to download an... (6 Replies)
Discussion started by: gencon
6 Replies

5. UNIX for Dummies Questions & Answers

Possible to download web page's text to a file?

Hi, Say there is a web page that contains just text only - that is, even the source code is just the text itself, nothing more. An example would be "http://mynasadata.larc.nasa.gov/docs/ocean_percent.txt" Is there a UNIX command that would allow me to download this text and store it in a... (1 Reply)
Discussion started by: Breanne
1 Replies

6. Shell Programming and Scripting

Perl script to copy contents of a web page

Hi All, Sorry to ask this question and i am not sure whether it is possible. please reply to my question. Thanks in advance. I need a perl script ( or any linux compatible scripts ) to copy the graphical contents of the webpage to a word pad. Say for example, i have a documentation site... (10 Replies)
Discussion started by: anand.linux1984
10 Replies

7. Shell Programming and Scripting

File to web page

Hi all, I am having an XML file. And as per requirement I need to map fields of this file with various field of web page. So how can I use wput command into it ? Regards, gander_ss (3 Replies)
Discussion started by: gander_ss
3 Replies

8. UNIX for Dummies Questions & Answers

Make a Web page

I'm 13 years of age and I am into computers. I am trying to learn how to make a webpage. I could use the help and I would greatly appriciate it. (1 Reply)
Discussion started by: lydia98
1 Replies

9. UNIX for Dummies Questions & Answers

Accessing Web Page

Hello, I am new to unix, but wanted to know how can we fetch data from a web page (i.e. an HTML Page), my requirement is to read an html page and wanted to create a flat file (text file) based on the contents available in the mentioned HTML page. Thanks Imtiaz (3 Replies)
Discussion started by: Imtiaz
3 Replies

10. Shell Programming and Scripting

linking unix generated text file to html page

i am trying to link the text files that i generated from my shell script to an html page, to that i can view them using a browser, like internet explorer. i want to open the text files in html page when i enter a command to view the text file from the shell command. please could anyone help... (1 Reply)
Discussion started by: alexd
1 Replies
Login or Register to Ask a Question