Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Help needed in printing the text

07 Sep 2015   #1
born2achieve

windows7 64 bit
 
 
Help needed in printing the text

Hello Friends,

I am having bunch of url and trying to check whihc url has broken. Finlly endup with creating powershell command. below the code working fine.
Code:
@echo off
powershell -command "gc 'links.txt'|%%{if($(try{[int][Net.WebRequest]::Create($_).GetResponse().Statuscode}Catch{}) -eq 200){$_}}|sc 'True_URL.txt'"
pause
But, Is there any way to print the running url? Right now i don't see what's happening on the screen. it's blank. But the process is running. I would like see which url is getting checked. Any suggestion please,
thanks


My System SpecsSystem Spec
.
07 Sep 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Hi there,

This should do,
Code:
@powershell "gc 'links.txt'|%%{'Processing: '+$_;if($(try{[int][Net.WebRequest]::Create($_).GetResponse().Statuscode}Catch{}) -eq 200){$_|ac 'True_URL.txt'}}"
pause
My System SpecsSystem Spec
07 Sep 2015   #3
born2achieve

windows7 64 bit
 
 

Hi PYP,

Thanks and it worked. But this process is dead slow and is there any better way to achieve this functionality. i have 100*1000 url's in text file.

Thanks
My System SpecsSystem Spec
.

07 Sep 2015   #4
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

I thought it was a little sluggish. The line you gave me fails to release the object returned by the GetResponse method. Bad memory leaks.

Try this,
Code:
@powershell "gc 'links.txt'|%{'Processing: '+$_;try{$r=[Net.WebRequest]::Create($_).GetResponse();if([int]$r.StatusCode -eq 200){$_|ac 'True_URL.txt'}}Catch{}finally{$r.Close()}}"
My System SpecsSystem Spec
07 Sep 2015   #5
born2achieve

windows7 64 bit
 
 

Thanks and getting error message when i run
Quote:
The string starting:
At line:1 char:119
+ gc 'links.txt'| '+$_;try{$r=[Net.WebRequest]::Create($_).GetResponse();if([int]$r.StatusCode -eq 200){$_|ac 'True_URL.txt <<<< '}}Catch{}finally{$r.Close()}}
is missing the terminator: '.
At line:1 char:149
+ gc 'mm.txt'| '+$_;try{$r=[Net.WebRequest]::Create($_).GetResponse();if([int]$r.StatusCode -eq 200){$_|ac 'True_URL.txt'}}Catch{}finally{$r.Close()}} <<<<
+ CategoryInfo : ParserError: (}}Catch{}finally{$r.Close()}}:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
any suggestion please
My System SpecsSystem Spec
07 Sep 2015   #6
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Sorry, it's probably the fancy formatting I've used that was interfering with your copy-paste. I've removed the colours now.
My System SpecsSystem Spec
07 Sep 2015   #7
born2achieve

windows7 64 bit
 
 

Sorry Dude, Still getting the error. am also analysis whats wrong.

Code:
@echo off
@powershell "gc 'links.txt'|%{'Processing: '+$_;try{$r=[Net.WebRequest]::Create($_).GetResponse();if([int]$r.StatusCode -eq 200){$_|ac 'True_URL.txt'}}Catch{}finally{$r.Close()}}"
pause
output:
Quote:
The string starting:
At line:1 char:119
+ gc 'mm.txt'| '+$_;try{$r=[Net.WebRequest]::Create($_).GetResponse();if([int]$r.StatusCode -eq 200){$_|ac 'True_URL.txt <<<< '}}Catch{}finally{$r.Close()}}
is missing the terminator: '.
At line:1 char:149
+ gc 'mm.txt'| '+$_;try{$r=[Net.WebRequest]::Create($_).GetResponse();if([int]$r.StatusCode -eq 200){$_|ac 'True_URL.txt'}}Catch{}finally{$r.Close()}} <<<<
+ CategoryInfo : ParserError: (}}Catch{}finally{$r.Close()}}:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

Press any key to continue . . .
My System SpecsSystem Spec
07 Sep 2015   #8
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Hm. The command line in the error message does not seem to match up with your code. Please retry that batch file.
My System SpecsSystem Spec
Reply

 Help needed in printing the text




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Help needed in Text file
Hi, I have a folder which has 20 text files and i need to find a word "Core" on the text files and and need to list out the file name where the text "Core" exists. for /R %%a in (C:\Sample\*.txt) do find "%Core" %%a >> output.txt But the above code is not working as expected. any sample code...
General Discussion
change line of text in word so it's laid out 90 degrees to other text?
Is this possible? In word 2013 i am making a for sale poster and i want to put phone numbers at the botton from left to right and cut between them with scissors so people can pull off the number as you have i'm sure seen many times. But how can i rotate the numbers so the text is at a 90 degree...
Microsoft Office
How can I stop printing things that are printing endlessly
I tried to print something but it started printing first a whole bunch of pages that I don't need anymore. It must be from the last time I pressed print but didn't connect the laptop with the printer.
General Discussion
Office 2007 Word printing deleted text over new text
Ok this is wierd I have a client using Office 2007 pro and some of her docs that she recently updated and the problem is when she prints the docs text that she deleted is printing over the top of new text she inserted into the doc. Now when you have said doc open in WORD the deleted text is not...
Microsoft Office
Change Desktop Icon Text but NOT Start Menu Text
Hello, I am trying to make my parents computer a little bit easier to use, so I made the desktop icons bigger and the text bigger using the following tutorial: http://www.sevenforums.com/customization/8916-changing-font-icon-text.html but it makes the start menu text also quite large which...
Customization
Printing to a text file
Hello I'm trying to print a report to a text file, but no luck yet. I know i had done it few month ago using Windows XP. I need to transfert data from my application to Excel and the easiest way is to print info as a .txt file and read it with Excel Any informations appreciated ...
Hardware & Devices


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 06:19.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App