user2505785
user2505785

Reputation:

Converting simple shell to cmd

I have a script which gets the public IP address and writes it to my dropbox folder.

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
wget http://ipecho.net/plain -O - -q > /home/lozicd3/Dropbox/IP/ip.txt

I want to achieve the same on my windows machines. Does anyone know how to translate it to CMD? I've tried Cygwin but can I do this without any external tools?

I was reading something about bitsadmin.

Thank you! :)

Upvotes: 0

Views: 70

Answers (2)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200303

You could use wget for Windows:

@echo off
setlocal
set PATH=%PATH%;C:\wget\folder
wget http://ipecho.net/plain -O - -q > %USERPROFILE%\Dropbox\IP\ip.txt

Upvotes: 1

user2505785
user2505785

Reputation:

Here we go:

@powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('http://ipecho.net/plain','C:\Users\myaccount\Dropbox\IP\ip2.txt')

Thanks anyway. :)

Upvotes: 1

Related Questions