Passing information to a file on webpage


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing information to a file on webpage
# 1  
Old 10-08-2013
Passing information to a file on webpage

ok so I have a file on a website. this file is a plain text file

i need to be able to update the contents of this file from any internet enabled unix box.

does anyone have ideas on how it can be done, without using scp/ftp?

i know wget can be used to download the file:

Code:
wget http://www.website.com/file.txt

But what else can i do to actually update the file?

let's say i want to update the file with the word "Success:193434", the ideal solution would be as simple as this:

Code:
wget "Success:193434" http://www.website.com/file.txt

OS: Linux/SunOS/AIX
# 2  
Old 10-09-2013
If it's on a website, why not update it directly?

Code:
$ cat updatefile.php
<?php
  $file = fopen( "file", "a" );
  fwrite( $file, "Success:193434\n" );
  fclose( $file );
?>

This User Gave Thanks to Scott For This Post:
# 3  
Old 10-09-2013
Quote:
Originally Posted by Scott
If it's on a website, why not update it directly?

Code:
$ cat updatefile.php
<?php
  $file = fopen( "file", "a" );
  fwrite( $file, "Success:193434\n" );
  fclose( $file );
?>

thank you.

how can i run this on any internet enabled host? so that it updates a file on the webpage? i would like for this to be done from the command line. possibly by passing the parameters to the script.
# 4  
Old 10-09-2013
The idea was that you add the file updatefile.php somewhere in your Webserver's document structure and call it using wget or curl.

For example:
Code:
$ curl http://webserver/updatefile.php
$ curl http://webserver/file
Success:193434
$ curl http://webserver/updatefile.php
$ curl http://webserver/file
Success:193434
Success:193434

You can modify the PHP to take parameters and update the file with those if you wished (so it doesn't have to be static updates).

i.e.
Code:
$ cat updatefile.php 
<?php
  $file = fopen( "file", "a" );
  fwrite( $file, $_GET['p1'] . " - " . $_GET['p2'] . "\n" );
  fclose( $file );
?>

Code:
$ curl http://webserver/updatefile.php"?p1=Hello&p2=World"
$ curl http://webserver/file                              
Success:193434
Success:193434
Hello - World

This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create file and file content based existing information?

Hi Gurus, I am SQL developer and new unix user. I need to create some file and file content based on information in two files. I have one file contains basic information below file1 and another exception file file2. the rule is if "zone' and "cd" in file1 exists in file2, then file name is... (13 Replies)
Discussion started by: Torhong
13 Replies

2. UNIX for Dummies Questions & Answers

Read version from a webpage and Upgrading the file.

Hi, I am trying to read version from a web url like <url/daily-builds/sdk-3.2.v20140312170355-osx.zip> and download and store in my filesystem if its the latest. Kindly help me how to read version 3.2.v20140312170355 and compare same with a folder named similar in my directory and... (1 Reply)
Discussion started by: pragyarastogi
1 Replies

3. UNIX for Dummies Questions & Answers

Grep? - using a file of terms to search another file when the information is on a different line

I have a flat file that looks like this, let's call it Chromosome_9.txt: FT /Gene_Name="Guanyl-Acetylase 9" FT /Gene_Number"36952" FT /Gene_Name="Endoplasmic Luciferase" FT /Gene_Number"36953" FT ... (4 Replies)
Discussion started by: Twinklefingers
4 Replies

4. Shell Programming and Scripting

Reading a string and passing passing arguments to a while loop

I have an for loop that reads the following file cat param.cfg val1:env1:opt1 val2:env2:opt2 val3:env3:opt3 val4:env4:opt4 . . The for loop extracts the each line of the file so that at any one point, the value of i is val1:env1:opt1 etc... I would like to extract each... (19 Replies)
Discussion started by: goddevil
19 Replies

5. Homework & Coursework Questions

Passing shell variables to a webpage

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is my assignment as a whole - Use SVG to present certain dynamic (the raw data should change at least once... (5 Replies)
Discussion started by: ChedWick
5 Replies

6. Shell Programming and Scripting

Splitting a file in to multiple files and passing each individual file to a command

I have an input file with contents like: MainFile.dat: 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 ... (4 Replies)
Discussion started by: rkrish
4 Replies

7. Shell Programming and Scripting

reading a file extracting information writing to a file

Hi I am trying to extract information out of a file but keep getting grep cant open errors the code is below: #bash #extract orders with blank address details # # obtain the current date # set today to the current date ccyymmdd format today=`date +%c%m%d | cut -c24-31` echo... (8 Replies)
Discussion started by: Bruble
8 Replies

8. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

9. Shell Programming and Scripting

Only the required tag information the XML file file

Hi i have a single line xml file having many account no tag, from which i need only the account no from the tag. any one can help on this. below is the xml file: ... (2 Replies)
Discussion started by: Saravanapk
2 Replies

10. Shell Programming and Scripting

cat a file on webpage

Hi, Is there a way to cat a file on Webpage? . Thanks in advance (3 Replies)
Discussion started by: rider29
3 Replies
Login or Register to Ask a Question