Download file to null (Windows CLI) - windows

I would like to download a file to null in windows cli just for testing purposes.
In linux i used
wget http://download.thinkbroadband.com/1GB.zip -O /dev/null
This kept my connection busy for a while.
Is there any way to do this in command prompt or power shell in windows 7?
Also other solutions to generate traffic from internet,ut withous saving it to disk, will be accepted.

Using Windows' (roughly) equivalent NUL device should mimic the Linux behaviour sufficiently:
wget http://download.thinkbroadband.com/1GB.zip -O NUL
Update: Recent builds of wget for Windows are available here.

You can use that exact same command on any Windows with Cygwin. Make sure you select Wget in the package list when installing Cygwin

Related

grep cf logs from windows machine

I am using the CloudFoundry CLI tool to tail logs from a remote cloudfoundry server. As per the cloud foundry log docs the command is
cf logs **app_name** --recent | grep RTR.
When i run this i get the error, grep is not recognized as a command. I believe this only works in a Unix based system. How can i use a grep like functionality from Windows CF CLI?
cf logs app_name --recent | findstr RTR
Findstr is capable of finding the exact text you are looking for in
any ASCII file or files. However, sometimes you have only part of the
information that you want to match, or you want to find a wider range
of information. In such cases, findstr has the powerful capability to
search for patterns of text using regular expressions.
Microsoft Technet
other solution would be that you install GNU grep on Windows. There are several ports available.
The Windows command prompt does not natively support bash prior to Windows 10, which is required for commands like grep. To use grep, you either have to use the git-bash shell provided during a git install, or in current releases of Windows, use the bash command in a Windows Command Prompt after installing the Windows Linux Subsystem. Windows Reference Documentation here
Perhaps you can use the git-bash if you have git installed on your machine. The git-bash comes with UNIX tools such as grep, so you would just open the git-bash instead of the Windows console and enter your command there.

Alternative command for Vi/Cat in Windows 7

In Unix/Linux we are having vi & cat command to view or edit a file. There are any alternative command to view/edit a file in windows command prompt.
Cygwin is a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.
It includes both cat and vi.
It is possible to select which parts of Cygwin to install. See Installing and Updating Cygwin Packages for more instructions.
There is a edit on windows but it doesn't work on 64Bit machine. So alternate solution is given below.
Just download vim for windows from Here (direct download link), on the installation it will ask if you want to create shortcuts for calling it from the command line. Then you can just vim
For Windows, To view the filename use, Type filename

How to start GNU Octave with GUI through Cygwin from a desktop icon?

Since GNU Octave comes wit a GUI since versions 3.8.0, I thought I should check it out.
So since I run Windows and could only find Octave 3.8 for Cygwin, I installed Cygwin and the packages octave, xinit, xlaunch and gnuplot (according to this page, but I don't know if all those packages are needed).
Then, when trying to start Octave with the GUI from Cygwin with octave --force-gui, I initially got the error message
octave: X11 DISPLAY environment variable not set
and Octave would start in console mode. So I found this page, which told me to run
echo "export DISPLAY=:0.0" >>~/.bash_profile
from Cygwin, to permanently get rid of the error message, which worked. However, then I instead got this error message:
octave: unable to open X11 DISPLAY
The same page also said that you have to run the X Server by going to Start -> Cygwin-X -> XWin Server. That worked, but since I don't want the xterm terminal to start since it is not needed, I found this page which told me to run
touch ~/.startxwinrc
from Cygwin to create an empty .startxwinrc file, to prevent the xtrem terminal from starting by default, which worked. The same page also mentioned that the X Server can be started directly from Cygwin with the command startxwin.
So, now I can start Octave with the GUI from Cygwin, simply by running
startxwin
octave --force-gui
However, I would like to just be able to double click on a desktop icon to get everything up and running.
So, to my question: Can I somehow put this in a script file, which when I run it, will be opened in Cygwin so that the commands in the script file will be run in Cygwin? And is there some way to automatically close the X Server after Octave has terminated? I've tried writing a file octave.bat, which starts Cygwin and gives a second batch file as argument, which in turn contains the commands I want to execute. But when I run the first script, I just get bombarded with command prompts (not Cygwin prompts), and the all say
'startxwin' is not recognized as an internal or external command, operable program or batch file.
Why is the second script not opened in Cygwin, and how can I achieve what I want as simply as possible?
Please grab Octave from here: http://mxeoctave.osuv.de/
The installer should configure everything for you.
GNU Octave offers now Windows binary itself. Go to ftp://ftp.gnu.org/gnu/octave/windows/
You have to put
c:\cygwin64\bin\mintty.exe /bin/sh -lc 'startxwin /bin/octave --force-gui'
in your windows batch file (please adapt the Cygwin path to your settings). That worked fine for me.
The call
c:\cygwin64\bin\bash --login -c "startxwin /bin/octave --force-gui"
did open Octave as desired but the GUI seemed to have response issues to the keyboard and froze after clicking into the editor.
I don't have any of the those commands installed with my Cygwin installation, so I can't test this by trying using the following an .bat file on your desktop:
c:\cygwin\bin\bash --login -c "startxwin octave --force-gui"
Replace c:\cygwin with the directory where you installed Cygwin.
If this leaves a console window on the screen try doing:
c:\cygwin\bin\bash --login -c "run startxwin octave --force-gui"

from R console windows equivalent of wget

Hi I was wondering what the windows equivalent of wget is
I currently have a function in R that has the command
system("wget www.random.url.com/file")
to download a file from the internet from a mac/unix machine that is running R...what would the equivalent be for R in windows?
Look at download.file to download files to your computer. This works on all operating systems, including Linux, Mac, and Windows.
powershell -command "iwr -outf abc.zip http://example.com/xyz.zip"

BAT script to copy files from Windows to remote Linux systems

Is there anyway to copy files from Windows machine to a remote Linux machine with a DOS command/other command-line tool (by specifying username and password in the command). I normally do this using WinSCP and would like to write a script (BAT) to automate this.
You could use the command line version of PuTTY, pscp.exe.
WinSCP scripting command-line to upload a file is like:
winscp.com /command "open sftp://username#example.com/" "put d:\www\index.html" "exit"
See the guide to WinSCP scripting.
Easier is to use a Generate transfer code function to have WinSCP GUI generate a script (or even a complete batch file) for a transfer.
Download a copy of pscp.exe (the PuTTY scp companion). If you have setup SSH keys on the Linux server, which you can do with PuTTY on Windows, you can setup password-less copy to Linux machines from Windows.
Install cygwin and you can use scp, ssh etc just like you would on linux. Besides, you can use ordinary bash scripts instead of crappy bat-files.
If anyone is looking to do this in 2022, Windows 10 now comes with scp. You can do
scp path/localfile.txt remote-user#host:/home/path
or the recursive version for directories
scp -r localfolder remote-user#host:/home/path
Of course with scp you'll run into issues if you have a large number of files. It copies everything as opposed to only changed / new files only.
Then you'll need a tool like rsync, which is available through WSL (windows subsystem linux).
rsync -r localfolder remote-user#host:/home/path
(I personally hesitate to install new tools for a job, hence my desire to stick with what's already available)

Resources