Is there a command similar in shell as it is in .NET VB RRS feed

  • Question

  • I was trying to download a file without going on the website and just getting sending through http request to the server. The server already has the subscription for my username and password.

    I wanted to know whether shell has any command similar to .NET's --> My.Computer.Network.DownloadFile(target,path,username,password). Or is there any other way to do the same thing?

    I dont want to go to the website and download the file. I just want to hit the server and get the response after passing my credentials.

    Can you please help me in finding this command?

    • Moved by Bill_Stewart Tuesday, July 22, 2014 6:39 PM Off-topic/unanswerable drive-by question
    Wednesday, June 25, 2014 6:47 PM

All replies

  • WGET can be downloaded and installed.

    No - batch shell language has no command.


    Wednesday, June 25, 2014 10:01 PM
  • Hi,

    I'd say System.Net.WebClient is your best bet, if you want an on-board solution available on every system that runs powershell. You can create one in Powershell using this command:

    $wc = New-Object System.Net.WebClient

    You will probably grow especially fond of its DownloadFile Method. You can also set credentials on the WebClient.
    And if you grow tired of typing it into the console again and again, you can turn it into a function.


    There's no place like

    Wednesday, June 25, 2014 10:17 PM
    $time_start = microtime(true);
    $targetNS= 'https://www.s.com/filesdownload/daily/20130308';
    $path = 'MySavedFile.zip';
    $user = 'username'; // your account name
    $pass = 'password'; // your password for the account
    * * Initialize the cURL setting up
    * * the option for the HTTPS.
    * */
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
    curl_setopt($curl, CURLOPT_USERPWD, $user.':'. $pass);
    curl_setopt($curl, CURLOPT_SSLVERSION,3);
    curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, "rsa_rc4_128_sha");
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($curl, CURLOPT_HEADER, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01;
    Windows NT 5.0)");
    curl_setopt($curl, CURLOPT_URL, $targetNS);
    * * Read the connection stream
    * * and save it in a file.
    * */
    print("Reading ZIP file.\n");
    $data = curl_exec($curl);
    $info = curl_getinfo($curl);
    file_put_contents($path, $data);
    $time_end = microtime(true);
    $reportTime = $time_end - $time_start;
    print("Done. ".$info['size_download']." bytes read (".$reportTime." seconds).

    I want to convert the above code in Shell. I have already tried it with the other way. Now I want to just get the response. Can you guys please please help me out with this?



    Thursday, June 26, 2014 11:56 AM
  • Wrong forum. PHP is not supported here or are any web systems.

    You must post in the forum for you version of the web server and PHP.  This forum is for admin scripting.

    If this is supposed to be PHP.Net then post in http://forums.asp.net


    Thursday, June 26, 2014 1:09 PM