Help running batch file on receive SMS

Help running batch file on receive SMS SearchSearch
Author Message
Michael Liu
New member
Username: Mbliu

Post Number: 1
Registered: 05-2010
Posted on Wednesday, May 12, 2010 - 12:35 pm:   

Hi. I'm using the latest trial version for NowSMS. I am trying to have every text msg received be logged in a text file.

On "Command to Execute" I have tried putting "C:\test.bat @@SENDER@@" and "C:\windows\system32\cmd.exe /c C:\test.bat @@SENDER@@" but neither works.

The bat file is just basically "echo %1 >> C:\test.log"

If I do "C:\windows\system32\cmd.exe /c echo @@SENDER@@ >> C:\test.log" it works! However, I want to eventually run other scripts on the SMS so this is unacceptable.

I am thoroughly confused at this...

Any help?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2097
Registered: 08-2008
Posted on Wednesday, May 12, 2010 - 05:27 pm:   

Hi Michael,

I'm confused as well.

If this works:

"C:\windows\system32\cmd.exe /c echo @@SENDER@@ >> C:\test.log"

But this does not work:

"C:\windows\system32\cmd.exe /c C:\test.bat @@SENDER@@"

... then I cannot imagine what the problem is, other than an elusive typo.

I tried a similar test here and the batch file worked just fine.

Can you add some other commands to your batch file to confirm whether or not it is running?

--
Des
NowSMS Support
Michael Liu
New member
Username: Mbliu

Post Number: 2
Registered: 05-2010
Posted on Wednesday, May 12, 2010 - 06:51 pm:   

The batch file also prints a timestamp. Running the batch file alone works fine. But no timestamp is printed when a text message comes, so the batch file is not even running.

I also tried initially with a python script but that doesn't work either. I've done this on two machines as well.

I'm using version 2010.02.09 which is the free trial version from the website.

The SMS Gateway log (smsdebug.log) used to log that the "command was executed" (but in fact it really wasn't..) However, now the log only displays one entry... "[0] main: Error 10048 from socket bind" dated whenever the program is started. There are never any subsequent entries anymore.
Michael Liu
New member
Username: Mbliu

Post Number: 3
Registered: 05-2010
Posted on Wednesday, May 12, 2010 - 06:55 pm:   

Also, this is running on Windows 7. Are there any file permission issues? I would think not as it is running as a service.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2101
Registered: 08-2008
Posted on Wednesday, May 12, 2010 - 07:06 pm:   

Hi Micheal,

I think the "Error 10048 from socket bind" is the current problem.

If the port for the web interface is not available, the service does not actually start. (There should be an error about this on the "Service" page of the NowSMS configuration program.)

Make sure that the port number specified on the "Web" titled page of the configuration program is not in use by another application. (Usually, the default 8800 port number is not a conflict.)

I'd also suggest the following tweak for your batch file:

@echo off
echo %1 >> C:\test.log
echo Thank you

On the NowSMS "2-way" page, check the "Command returns response text" option. You should receive a reply back that says "Thank you" when the command runs. And we should see this activity in the SMSDEBUG.LOG as well. I'm thinking this will help in troubleshooting whether or not the batch file is running.

--
Des
NowSMS Support
Michael Liu
New member
Username: Mbliu

Post Number: 4
Registered: 05-2010
Posted on Thursday, May 13, 2010 - 03:16 am:   

I changed the port to something random and the log file does show up normally now. I changed the batch file as you suggested and I do receive a "Thank you" response text. However, the test.log file is still not appended to. The smsdebug.log shows that the command has been executed.

Any ideas?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2112
Registered: 08-2008
Posted on Thursday, May 13, 2010 - 03:30 pm:   

Hi Michael,

Maybe it is a rights issue?

Try removing the ">> c:\test.log" ... in other words:

@echo off
echo %1
echo Thank you

The SMS reply that you receive now should have the sender address at the start of it.

If this works, it definitely suggests that it must be a rights issue. I would try different filenames/directory locations.

--
Des
NowSMS Support