POSSA / freepbx-weather-by-zip

FreePBX module, reads back weather forcast from dtmf zip code input
4 stars 5 forks source link

PHP Coding Problem w/ editor #11

Closed lgaetz closed 12 years ago

lgaetz commented 12 years ago

Attention @tm1000 and @POSSA

This commit: https://github.com/POSSA/freepbx-weather-by-zip/commit/855276f0b7631a010afeb3267397b2ed262af4a1

made one very minor change to the /agi-bin/nvweather-zip.php file but my editor did something to the file and now it doesn't work anymore on my system. The only thing I can do to make things work is to restore the original nvweather-zip.php from the 2009 tarball.

The only way I can edit this file and have it remain working is to use nano, none of the windows editors I use are working for me. I have edited a lot of PHP with windows editors and never ran into this, can anyone help?

tm1000 commented 12 years ago

I think it's the very first line, the one that tells the system what interpreter to use. Looks like you added a rouge windows character to it and perhaps linux is getting confused by that

(remember, linux returns lines using \n windows does \n\r)

lgaetz commented 12 years ago

Yeah, I am guessing it has to to do with unix newlines, but I don't know why it has never happened to me before today. If I perform a weather query with the original file it works fine. As soon as I edit it with any windows editor it will proceed thru the dial plan and instantly hang up the call when the nvweather-zip.php script is called.

Here is full asterisk log with a successful weather query:

[2012-05-03 15:00:40] VERBOSE[8250] pbx.c:     -- Executing [s@noah-flite:8] AGI("SIP/201-000000bd", "nvweather-zip.php,90210") in new stack
[2012-05-03 15:00:40] VERBOSE[8250] res_agi.c:     -- Launched AGI Script /var/lib/asterisk/agi-bin/nvweather-zip.php
[2012-05-03 15:00:42] VERBOSE[8250] res_agi.c:     -- <SIP/201-000000bd>AGI Script nvweather-zip.php completed, returning 0
[2012-05-03 15:00:42] VERBOSE[8250] pbx.c:     -- Executing [s@noah-flite:9] NoOp("SIP/201-000000bd", "Wave file: tts/tts-6c10b186ab9de7e66ae213eb49e1799d") in new stack
[2012-05-03 15:00:42] VERBOSE[8250] pbx.c:     -- Executing [s@noah-flite:10] Playback("SIP/201-000000bd", "tts/tts-6c10b186ab9de7e66ae213eb49e1799d") in new stack
[2012-05-03 15:00:42] VERBOSE[8250] file.c:     -- <SIP/201-000000bd> Playing 'tts/tts-6c10b186ab9de7e66ae213eb49e1799d.slin' (language 'en')
[2012-05-03 15:00:44] VERBOSE[8250] pbx.c:   == Spawn extension (noah-flite, s, 10) exited non-zero on 'SIP/201-000000bd'

Here is full asterisk log after a failed weather query

[2012-05-03 14:55:45] VERBOSE[8167] pbx.c:     -- Executing [s@noah-flite:8] AGI("SIP/201-000000bb", "nvweather-zip.php,90210") in new stack
[2012-05-03 14:55:45] VERBOSE[8167] res_agi.c:     -- Launched AGI Script /var/lib/asterisk/agi-bin/nvweather-zip.php
[2012-05-03 14:55:45] ERROR[8167] utils.c: write() returned error: Broken pipe
[2012-05-03 14:55:45] ERROR[8167] utils.c: write() returned error: Broken pipe
 ... 35 or so broken pipe errors deleted ...
[2012-05-03 14:55:45] ERROR[8167] utils.c: write() returned error: Broken pipe
[2012-05-03 14:55:45] ERROR[8167] utils.c: write() returned error: Broken pipe
[2012-05-03 14:55:45] VERBOSE[8167] res_agi.c:     -- <SIP/201-000000bb>AGI Script nvweather-zip.php completed, returning 0
[2012-05-03 14:55:45] VERBOSE[8167] pbx.c:     -- Executing [s@noah-flite:9] NoOp("SIP/201-000000bb", "Wave file: ") in new stack
[2012-05-03 14:55:45] VERBOSE[8167] pbx.c:     -- Executing [s@noah-flite:10] Playback("SIP/201-000000bb", "") in new stack
[2012-05-03 14:55:45] WARNING[8167] app_playback.c: Playback requires an argument (filename)
[2012-05-03 14:55:45] VERBOSE[8167] pbx.c:   == Spawn extension (noah-flite, s, 10) exited non-zero on 'SIP/201-000000bb'
lgaetz commented 12 years ago

Thinking it might just be an issue between unix text and windows text, I tried using the unix command dos2unix but that doesn't fix a non-working file.

lgaetz commented 12 years ago

I found the problem. My git client knows I am on a windows system so it automatically converts unix newlines to windows newlines, then when i transfer to my unix server the format is wrong. I just need to add an extra step and make sure to transfer files directly from Github to Centos not thru windows first. What a pain.

screen cap of what SmartGit file transfers: https://lh5.googleusercontent.com/-2cSyWaau1Z0/T6QWQLsKERI/AAAAAAAAA9I/5c2RwgGln6I/s477/gitcommit.jpg