Catch SMS Before NowSMS 2way does

Catch SMS Before NowSMS 2way does SearchSearch
Author Message
Raimonds
New member
Username: Raimonds

Post Number: 1
Registered: 09-2015
Posted on Thursday, September 24, 2015 - 05:18 pm:   

Hello everyone,
Is it possible to catch incoming sms before NowSms 2way Does?

Basically idea is to use 2-way system to test my network connection and ping VARIOUS Ip addresses.
For example my text would look something like:

Ping: 127.0.0.1
( prefix ) (Various IP)

and reply from nowsms would be

IP 127.0.0.1 status : UP

It works great when I have hard coded IP (127.0.0.1) in script. However the goal is to pull out IP address (Or anything really) from incoming sms into my PS before 2way sms sends out cmd output.

Would it be stored in %Temp%? what would be the name of it? Would it be different each time? I could set up file watcher and pull out IP into PS before 2way system will execute it and send CMD output as reply.

Or maybe there is a way I can use autoreply function with this?

I know this is confusing, i tried to explain myself as clear as possible. Any help would be highly appreciated. Thank you!
Raimonds
New member
Username: Raimonds

Post Number: 2
Registered: 09-2015
Posted on Sunday, September 27, 2015 - 06:45 am:   

bump
Learned a bit about sending sms from cmd, but is it possible to read incoming sms through cmd? That would kinda sort out my above question. Thanks
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5458
Registered: 08-2008
Posted on Monday, September 28, 2015 - 06:42 pm:   

Hi,

Sorry for the delay in response.

I was a little confused about why you wanted to bypass 2-way SMS, as it would seem to me that is what you would want to use.

A 2-way command could be a local program, script or batch file (or HTTP link).

For a local command, whatever it echoes back can be automatically sent as a reply.

In the 2-way command parameters, @@SMSPREFIX@@ will be replaced with the first word of the message, and @@SMS@@ will be replaced with all text after the first word.

Or use @@FULLSMS@@ for the complete text.

As a simple example, we use a keyword of * and a command of c:\windows\system32\cmd.exe /c echo Echo @@FULLSMS@@

As long as "Reply to sender with command output" is checked, the system replies back with the same text preceded by Echo.

--
Des
NowSMS Support
Raimonds
New member
Username: Raimonds

Post Number: 3
Registered: 09-2015
Posted on Monday, September 28, 2015 - 10:00 pm:   

Thank you for reply.
What I want to do is text Ping(prefix) 192.168.0.1 # "Ping" prefix is linked to .bat which executes ping command. However I want to be able to Ping various IP addresses. Like my getaway or other workstations on Lan. Would that be doable?

I have script which finds getaway IP without me manually declaring it like this:

@For /f "tokens=3" %%* in (
'route.exe print ^|findstr "\<0.0.0.0\>"'
) Do @Set "DefaultGateway=%%*"

@echo off
ping -n 1 %DefaultGateway% >nul
if errorlevel 1
(
echo Getaway Status : DOWN
)
cls
echo Getaway Status : UP
exit

However it is not exactly what I would Like
Raimonds
New member
Username: Raimonds

Post Number: 4
Registered: 09-2015
Posted on Monday, September 28, 2015 - 10:29 pm:   

Yes this does work great.
Here's what I did.

Prefix Example
//cmd command

c:\windows\system32\cmd.exe /c ping -n 1 @@SMS@@

Incomig msg Example 192.168.0.1

This is great! But what would be the best way to drag in Ip address into my own batch file?

Lets Think of something like adding user to Active directory through CMD.
comand I would use would be: (Lets say would have this command into .bat)
## net user username password /ADD
How would I go about this. How would I pull in username and password into my .bat and then execute it?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5461
Registered: 08-2008
Posted on Monday, September 28, 2015 - 11:41 pm:   

It's been awhile since I've done anything like this, but when you run a batch file as a command (or from a command line), there is a parameter syntax that you can use in the batch file where command line parameters are available as %1, %2, thru %9.

So if I remember correctly ... for example consider this command:

c:\windows\system32\cmd.exe /c c:\path\mycmd.bat @@SMS@@

Contents of c:\path\mycmd.bat:

@echo off
ping -n 1 %1


I also recall a shift command which is useful if you want to loop through a variable number of parameters.

--
Des
NowSMS Support