hi,

I've been playing around with php on the command line. I've discovered that there is lots I can do with STDIN and STDOUT! I'm still not quite sure of all what they can do, but I can see what they do, that stdin will take a person's input from a command line and stdout will output things. I have a few questions though.

first. I noticed that if you just use echo to output text when using stdin, the echo statements don't show up until you enter in all of what the script wants you to enter in. but I found out that stdoutoutputs until the next stdin...so I mean if you want to have it output: "your name", and then stop until you enter your name, that only stdout works for that. would that be correct? echo for me didn't work until after I put in my name, then after that asking for the name is a little pointless.

ok, then, say I was trying to make an ftp script by command line. I put some stuff in a batch file, to run the php file, and I go to the batch file. it asks for host, port, then connects and gives a success message, then asks for username and password, etc etc. so all the normal php ftp functions are possible through this. but, how about uploading and downloading?

  1. when using the web server with an ftp php script, you can use the upload through post method to get your files to where the script is, and then upload from there to the server. when your just going by command line, though, how can you do something like this, or is it even possible? like say I want to upload my local file C:\www\index.php to the ftp server in /www/index.php. how would you do such a thing without the availability of the post method upload?

  2. even further, when working with an ftp script on the web server, you can download the file from the ftp server to the server where the script is, and force a download to begin so that the person can click save or open or whatever they feel like doing and save it on their computers. but, well I wouldn't think, on a command line sort of a deal, you wouldn't have the availability of headers, like content-type, and content-disposition to force a download...so is there any way to do what I mentioned above?

any help is appreciated, I'm just curious. I'll attach what I have of my script...though it was thrown together quickly last night and today, and I threw in the functions I needed from another script...and so its all discombobulated, but still it works 🙂.

Brandon

    The output is only done on receipt of a \n.
    You can try to force the output using flush().

    You have to think command line not web.
    You have to tell your script what to do.

    If you want to upload a file to your web server write a script to do that.

    If you want to download from your server either give the script an option for up/download or write another script to do the job.

    HalfaBee

      Write a Reply...