Problem with shell and ping

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jackads
Posts: 6
Joined: Wed Aug 22, 2012 2:12 pm

Problem with shell and ping

Post by jackads » Thu Sep 27, 2012 5:22 pm

Hello guys,
I'm trying to use the "ping" command in the shell, but it don't work. =/

When I try

Code: Select all

answer shell("ping 192.168.1.1")
--or
put shell("ping " & destino & pacotes & buffer) into field "Console"
imageshack.us/a/img27/4523/pingfail.jpg (my account can't post links or references =/)

"Ping isn't a command, program or batch file" =/
Like if ping doesn't exists, I don't know.
When I open the cmd and write the ping command it normally execute, but when I try to get the shell in livecode it tell me ping isn't a command, why?

Sorry the English, and thanks for the attention, God bless you all!

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Problem with shell and ping

Post by mwieder » Thu Sep 27, 2012 6:11 pm

What OS is this? Ping will normally run forever until it's canceled, so you probably want to say something like

Code: Select all

put shell("ping -c4 192.168.1.1")
Which will try four times and then return.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Problem with shell and ping

Post by sturgis » Thu Sep 27, 2012 7:41 pm

The most likely problem is that the path environment is not the same when using lc shell. When you go to a command prompt you get a full shell, with a path that probably points to the folder where ping is.

Find where the ping command sits and give a full path to the executable.
jackads wrote:Hello guys,
I'm trying to use the "ping" command in the shell, but it don't work. =/

When I try

Code: Select all

answer shell("ping 192.168.1.1")
--or
put shell("ping " & destino & pacotes & buffer) into field "Console"
imageshack.us/a/img27/4523/pingfail.jpg (my account can't post links or references =/)

"Ping isn't a command, program or batch file" =/
Like if ping doesn't exists, I don't know.
When I open the cmd and write the ping command it normally execute, but when I try to get the shell in livecode it tell me ping isn't a command, why?

Sorry the English, and thanks for the attention, God bless you all!

jackads
Posts: 6
Joined: Wed Aug 22, 2012 2:12 pm

Re: Problem with shell and ping

Post by jackads » Thu Sep 27, 2012 9:47 pm

You're completely right sturgis!
The full path is "C:\Windows\System32\ping", now it works great!

mwieder, my desktop OS is Windows 7 and my netbook OS is openSUSE, in windows and linux the default count parameter is 4, unlike to the infinity loop on Mac OS X, and others apple's OS (I think).

Thanks for the help guys, God bless you!

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Problem with shell and ping

Post by mwieder » Thu Sep 27, 2012 10:07 pm

Well, there's linux and there's linux.
My fedora core 16 ping also goes to infinity unless told otherwise. As do all the linux distros I've worked with lately.
Anyway, I'm glad you've got a solution, although I'm surprised that ping isn't in the Win7 path.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Problem with shell and ping

Post by sturgis » Fri Sep 28, 2012 12:34 am

Seems like its just not in the lc environmental path from the description. I suspect opening cmd as a process and then running ping might work, will have to see when I am back on windows next. Currently am playing with ltsp on ubuntu server though so no chance to do so for a bit.

I'd be curious to know what get shell("set") returns for the path env variable on your machine jackads, does it point to system32? And what about if you do put $PATH from the message box? Do they match?

I've run in to this sort of thing with lc before where the environment at a prompt doesn't match, and so have to work around the problem, but its been long enough since it happened that I don't recall what the trouble was.

Maybe there is a difference when running in 64bit win 7, but lc is 32bit so perhaps there is an extra layer in there somewhere.
mwieder wrote:Well, there's linux and there's linux.
My fedora core 16 ping also goes to infinity unless told otherwise. As do all the linux distros I've worked with lately.
Anyway, I'm glad you've got a solution, although I'm surprised that ping isn't in the Win7 path.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Problem with shell and ping

Post by mwieder » Fri Sep 28, 2012 12:45 am

Yeah, I'm not at a Windows box right now either. I'll check this out myself when I get the chance.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Problem with shell and ping

Post by mwieder » Fri Sep 28, 2012 2:18 am

Update: ping.exe is in the path on both xp and Win7 64-bit. It's in C:\Windows\system32. The shell command should pick it up. Are you possibly running as a non-admin user with restricted privileges?

Post Reply