Solved

how to built win batch programe for listed algorithm  and   checking status of ping request to PC .

Posted on 2007-12-06
5
304 Views
Last Modified: 2013-12-03
dear experts ,

1)Checking the ping request status to PC by the win batch script .( should be able to return flag based  either success/failed request)

2)How to prepare the part  of code in batch  script for  the following algorithm
             [Comparing the two string ]

Str1=der
Str2=hyt

If  str1=str2
     &&.
Else
        &&&&.
End if .

0
Comment
Question by:mansur_mca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 26

Accepted Solution

by:
farhankazi earned 400 total points
ID: 20426036
1) To check Ping response you can use following batch script.

@ECHO OFF
SET RmtSystem=JPAKK1
PING -n 2 -w 800 %RmtSystem% |FIND /I "TTL" >NUL
IF NOT ERRORLEVEL 1 (
	ECHO Remote System is UP!
)ELSE (ECHO *ERROR* %RmtSystem% System Offline.)
EXIT /B 0

Open in new window

0
 
LVL 26

Assisted Solution

by:farhankazi
farhankazi earned 400 total points
ID: 20426050
For comparing the two string (case sensitive) you can use following batch code.
For case insensitive you can use /I switch with IF statement.
Like:
IF /I "%Str1%"=="%Str2%"
@ECHO OFF
SET Str1=Hello
SET Str2=Hello
 
IF "%Str1%"=="%Str2%" (
	ECHO Match
)ELSE (ECHO Mismatch)
EXIT /B 0

Open in new window

0
 
LVL 1

Author Comment

by:mansur_mca
ID: 20427087
excellent  farhan ,  it is so nice .

can you please explain bit more about line that have used in your reply .
PING -n 2 -w 800 %RmtSystem% |FIND /I "TTL" >NUL .

Your  solution much appreciated, I spent much of time on net to find the solution for this  command line.
thanks agian to you .
0
 

Assisted Solution

by:cgosney42
cgosney42 earned 100 total points
ID: 20429173
@mansur_mca
This line is a combination of two commands.
The "|" symbol takes the result of the first command and "pipes" it through the second command.

Command 1:
At a command prompt type ping /? to see the syntax for PING.  This pings a station which is identified in the system variable RmtSystem.  This was set in line 2.
The -n 2 is the number of responses to look for and w is the timeout.

Command 2:
Takes the result of the Ping command and searches for the text "TTL".
Since displaying the result is not necessary, this is sent to NULL.

ERRORLEVEL 1 occurs if the host isn't found.

For more information on all DOS commands, type [command] /? at the command prompt.
0
 
LVL 1

Author Comment

by:mansur_mca
ID: 20433099
Great , excellent trick.
I have tested for the soultion that you advised as above. gone though well .

thanks much ...
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question