[php] ftp get all files from a certain file type


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [php] ftp get all files from a certain file type
# 8  
Old 05-20-2009
Those concepts are -kind of- familiar to me, but it would be a lot clearer in form of a code example. Thx in advance
# 9  
Old 05-25-2009
I have
Code:
$fh = fopen('ftpservers.txt','r');
while (!feof($fh)){
  $line = fgets($fh);
  echo $line;
}
fclose($fh);

ftp_close($conn_id);

How can I put line1 in $ip, line2 in $user and line3 in $pwd
Afterwards it have to pass on to line4 that gets to be $ip, line5 $user and line6 $pwd, line7 as $ip, etc...

Thanks in advance!
# 10  
Old 05-25-2009
Without any experience with PHP (so there may be some syntax errors in the code Smilie), I can give some idea to start with.
I use an array , a counter i and a mod operator to index the array:

Code:
$fh = fopen('ftpservers.txt','r');
$i=1
while (!feof($fh)){
  $line[$i % 3] = fgets($fh);
  if ($i % 3 == 0) {
    echo $line[1];
    echo $line[2];
    echo $line[0];
  }
  $i++;
}
fclose($fh);

ftp_close($conn_id);

Regards
# 11  
Old 05-25-2009
I appreciate your effort Franklin, but unfortunatly I get...
Code:
Parse error: syntax error, unexpected T_WHILE in /home/backupscript.php on line 88

Can somebody check the syntax ?

Probably bash and PHP are kind of different Smilie

Thanks in advance
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Move Multiple Files adding date timestamp before file type

There are files in a directory and I have to move multiple files adding datetimestamp before the file type. /Data/ abc.csv def.csv ghi.csv I have to move this files to archive directory adding datatimestamp before .csv /archive/ abc_YYYYMMDDHHMMSS.csv def_YYYYMMDDHHMMSS.csv... (7 Replies)
Discussion started by: eskay
7 Replies

2. Shell Programming and Scripting

How to ftp multiple files by taking the file name from a input file.

Hi, I'm working on a script which has to copy multiple files from one server to another server. The list of files that are to be copied is present in a file say input.txt. vi input.txt abc.c welcome.c new.c welcome1.c for ftp'ing a single file say 'new.c' the following code... (2 Replies)
Discussion started by: i.srini89
2 Replies

3. Shell Programming and Scripting

Deleting all files recursively from directories while ignoring one file type

Hi, Seems like I need help again with a problem: I want to delete all files from my lets say "Music" Directory inkluding all of the subfolders except for .mp3 and .MP3 files. I tried it with globalignoring mp3 files, finding and deleting all other files, which resulted in all files... (3 Replies)
Discussion started by: pasc
3 Replies

4. Shell Programming and Scripting

write to multiple files depending on file type (solved)

I want a script that will add comments to a file before check-in files. comments depend on type of files. i have a script to list files in the directory that will be checked-in There are xml, js, html, vm files. vm will use comments like c/c++ ( // or /*..*/) can you help me add a comment line... (0 Replies)
Discussion started by: pradeepmacha
0 Replies

5. Programming

type command in PHP

Hello, I am having trouble getting the type command to work in PHP whereas it works fine on the command line with only certain functions... example from PHP script: echo system('type cp'); returns cp is /bin/cp whereas echo system('type mogrify'); returns nothing... whereas from the unix... (1 Reply)
Discussion started by: dave_c00
1 Replies

6. Windows & DOS: Issues & Discussions

Batch file to Get New Files Only through FTP

Hi there I want to create a batch file which Get (mget) the newly added Files only from specific directory on UNIX server to specific folder on windows server using FTP, and this batch file will be scheduled on the windows server to run daily to load the new files (load the newly added files... (1 Reply)
Discussion started by: alsharq
1 Replies

7. Windows & DOS: Issues & Discussions

Batch file to Get New Files Only through FTP

Hi there I want to create a batch file which Get (mget) the newly added Files only, from specific directory on UNIX server to local folder on windows server through FTP, and this batch file will be scheduled to run daily to load the new files. help me plz :confused: (1 Reply)
Discussion started by: alsharq
1 Replies

8. Linux

Output to 1 file from two files in FTP

I am currently in FTP. I want to transfer two files and need the out put in One file. Can you help me.... For eg: if i am doing mget from 1 server to other. (1 Reply)
Discussion started by: manish.s
1 Replies
Login or Register to Ask a Question