cathcing `mozilla -remote ping()` within c++


 
Thread Tools Search this Thread
Top Forums Programming cathcing `mozilla -remote ping()` within c++
# 1  
Old 06-27-2005
catching `mozilla -remote ping()` within c++

Here is my problem. An extension and alternative to my initial post https://www.unix.com/shell-programming-and-scripting/18043-browser-variable.html

This is what I have done so far to counter it.

In my application, I have used

Code:
/usr/bin/mozilla -remote "openURL(URL)"

The -remote makes sure that I go and open the URL in an existing instance of mozilla.

This is what is happening inside. I start the server. Login with a user. Sync the data on the client. After that the server restarts itself and gives a login page to the user who just did the sync.

If I am user U1 and have the server running in the context of U1, then the above will work.

But if I am user U2 on the same machine, using the server running on U1, then while doing an execv on the above shows me the following at the prompt of U1.

No running window found.

This message is shown when mozilla doesnt find a running instance of the /usr/bin/mozilla.

Now, there is another option,

Code:
/usr/bin/mozilla -remote "ping()"

which will tell me if there is an instance of mozilla running or not. My problem is how can I capture the result of the above ping command inside my application.(if it possible).

Possible work-arounds that you may come up is:
1. Give a
Code:
/usr/bin/mozilla "openURL(URL)"

. I know that and do not want to use that.
2. Use /usr/bin/mozilla -remote "ping()" in a shell script. I need to run the whole thing within the context of the application. No using external scripts.

uname -a is
Linux xxxxxxx 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux

I will try to give you as much details(if needed), but I cant give out the code. Company policy.

Thanks,
vino

Last edited by vino; 12-17-2005 at 06:10 AM..
# 2  
Old 10-02-2005
Looks like no one has faced this problem before.

Anyway here is a solution. I am exploiting the following fact.

Code:
@mozilla is not running for user1.
[user1]$ mozilla -remote ping()
No running window found.
[user1]$ echo $?
2
[user1]$

Code:
@mozilla is running for current user1
[user1]$ mozilla -remote ping()
[user1]$ echo $?
0
[user1]$

Which means if there is no instance of mozilla running, then it throws up No running window found. i.e. output will come via stderr

To confirm the above case, here is a snippet of the relevant lines from the strace output.

Code:
write(2, "No running window found.\n", 25No running window found.
) = 25

If there is an instance of mozilla running, then no such line will be found.

Here is the relevant code.

Code:
#include <stdio.h>
#include <string.h>
main()
{
        FILE* pipe;
        char str[25] = { 0 };
        pipe=popen("/usr/bin/mozilla -remote \"ping()\" 2>&1","r");

        // No running window found. 
        // or 
        // Error: No running window found.        
        // is what we are trying to capture. 
        // Anything else, is same as nada.

        // Caution.
        // Might have to increase the size from 25 to 32
        fgets(str,25,pipe);
        printf("%s",str);

        pclose(pipe);
}

Based on the contents of str, we can move ahead.

Vino

Last edited by vino; 12-17-2005 at 06:13 AM.. Reason: Recent change in mozilla's error message
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies

2. Shell Programming and Scripting

Ping the service with out port number on remote network

I got the service status through nc on remote network but 2 services doesn't have port number.how to get the other 2 services status with out port number .pls provide the solution to me. I need to develop with is in a script (2 Replies)
Discussion started by: kannansoft1985
2 Replies

3. BSD

Ping remote sever, nc, telnet, whatever

I put this thread to shell and bsd, because I want to resolve this matter on bsd. May somebody can explain to me how to ping a remote server, in unix. BTW the following code examples were tried on a linux system as well, with the same output, nothing. But on my bsd are not installed nmap neither... (4 Replies)
Discussion started by: 1in10
4 Replies

4. AIX

Ping to remote host failed

Actually. I was getting a ping to remote host failed for one of my etherchannel. When I checked it was in backup adapter and again I use to faileover and brought to primary channel. But it was again going to backup channel and giving me the alert ping to remotehost failed. When I checked the load... (3 Replies)
Discussion started by: Mohamed Thamim
3 Replies

5. Shell Programming and Scripting

How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi I am using perl to ping a list of nodes - with script below : $p = Net::Ping->new("icmp"); if ($p->ping($host,1)){ print "$host is alive.\n"; } else { print "$host is unreacheable.\n"; } $p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies

6. Shell Programming and Scripting

Animation Ping on Solaris Like Cisco Ping

Hi, I develop simple animation ping script on Solaris Platform. It is like Cisco ping. Examples and source code are below. bash-3.00$ gokcell 152.155.180.8 30 Sending 30 Ping Packets to 152.155.180.8 !!!!!!!!!!!!!.!!!!!!!!!!!!!!!. % 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 Replies

7. Programming

Ping remote UNIX machine from a java application

Hi Friends, Can some one please guide me on how to make a script run on a remote UNIX machine from a java application. Or may if you can just tell me how do u ping to the remote UNIX machine using java code. Been looking for the solution since 5-6 hrs, didn't got any where near :( Thanks. (1 Reply)
Discussion started by: Sanjay MD
1 Replies

8. Solaris

Mozilla 1.7 and java 1.6

Hi community, I've a problem with mozilla 1.7. I'm working on Sun Workstation with Solaris10 and I just installed java 1.6_0 but when I start a GUI from a remote Server I see that the version is still 1.5. the output of " java -version" shows 1.6. Maybe is a problem with a mozilla link... (1 Reply)
Discussion started by: Sunb3
1 Replies

9. Shell Programming and Scripting

issue a ping on a remote box

Hi there I am running a script on a central box (boxA) that will send a remote request to boxB to perform a ping test to an ip note: I am not pinging boxB from boxA but sending a request over ssh to get boxB to perform a ping test ! The thing is, I want the script back at boxA to know... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

10. SCO

Openserver 5.0.4 can't be ping or telnet into from a remote site

Hi, Can anybody help me out why l can't not ping my server with Openserver 5.0.4 with my windows machine from a remote site. The machine could see the local LAN with the Router however, i can't ping or telnet unto the server from another site on the WAN. The default gateway was configure on the... (0 Replies)
Discussion started by: kayode
0 Replies
Login or Register to Ask a Question