Извините, ничего не найдено.

Не расстраивайся! Лучше выпей чайку!
Регистрация
Справка
Календарь

Вернуться   forum.boolean.name > Программирование игр для мобильных телефонов > MidletPascal > Проекты на MidletPascal

Ответ
 
Опции темы
Старый 20.03.2010, 15:20   #1
spownc
AnyKey`щик
 
Регистрация: 15.03.2010
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Аналог "cmd" на мобиле...

ДаЁва всем!
Ситуёвина такая: мне, по долгу профессиональному, бывает необходимо пользоваться командной строкой. А случается, что под рукой её нет - а
"Срочно надо!"
Я, как человек не по "наслышке" знаком с разными ОСями, помимаю, что идея написать реальное сетевое ПО под мобильную яву - мягко говоря бредовая, но... Всё же!

Интересует хотябы ping, traceroute, telnet...

Есть у кого исходник? Ну хоть наброски?! Реально очень надо!

Чуть не забыл... Я имел ввиду именно MidletPascal !
Но не откажусь от любого варианта))
Спасибо заранее!!!

Последний раз редактировалось spownc, 20.03.2010 в 15:25. Причина: IDE...
(Offline)
 
Ответить с цитированием
Старый 20.03.2010, 16:32   #2
Phantom
Элита
 
Аватар для Phantom
 
Регистрация: 14.06.2008
Адрес: Украина, Киев
Сообщений: 2,273
Написано 754 полезных сообщений
(для 1,833 пользователей)
Ответ: Аналог "cmd" на мобиле...

Телнет в принципе реально. Пинг и трэйсроут скорее всего никак. По крайней мере на Джава (МП).
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
spownc (25.03.2010)
Старый 20.03.2010, 16:56   #3
spownc
AnyKey`щик
 
Регистрация: 15.03.2010
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Аналог "cmd" на мобиле...

Сообщение от Phantom Посмотреть сообщение
...по крайней мере на Джава (МП).
А на чем еще можно?
(Offline)
 
Ответить с цитированием
Старый 20.03.2010, 17:07   #4
jimon
 
Сообщений: n/a
Ответ: Аналог "cmd" на мобиле...

spownc
купи нормальный мобильный пк, благо уже полно вариантов, хотя бы N900, там ping, traceroute из коробки, ssh поднимается в два нажатия
 
Ответить с цитированием
Эти 4 пользователя(ей) сказали Спасибо за это полезное сообщение:
ABTOMAT (20.03.2010), impersonalis (20.03.2010), Phantom (20.03.2010), Rock2roll (06.08.2010)
Старый 24.03.2010, 08:04   #5
spownc
AnyKey`щик
 
Регистрация: 15.03.2010
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Аналог "cmd" на мобиле...

Сообщение от jimon Посмотреть сообщение
spownc
купи нормальный мобильный пк
В том-то и дело... Был у меня КПК (Qtek g100). Я на нем делал всё без проблем (Там WM5), в лужу упал...
И вот пока я не куплю другой - нужна замена его 2х-3х функций. Именно по этому заинтересовался мобильной платформой... Телефон у меня Nokia 5130 XpressMusic Series 40.
(Offline)
 
Ответить с цитированием
Старый 24.03.2010, 13:04   #6
cherepets
Бывалый
 
Регистрация: 18.08.2009
Сообщений: 745
Написано 146 полезных сообщений
(для 215 пользователей)
Ответ: Аналог "cmd" на мобиле...

блин, сначала подумал что ты ошибаешься, потому что так 9ка...
а, оказалось это я перепутал, 5320 - внешне почти 1в1 тел, но 9.3 симба...

а по теме, ну, думаю пинг при желании замутить самому можно, а остальное - сильно сомневаюсь(( (хотя и в пинге не уверен, но ведь ес самому генерить кучу запросов - выйдет, нет?)
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
spownc (25.03.2010)
Старый 24.03.2010, 13:23   #7
spownc
AnyKey`щик
 
Регистрация: 15.03.2010
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Аналог "cmd" на мобиле...

Сообщение от cherepets Посмотреть сообщение
...самому генерить...
ВОООТ, а как их генерить?
Просто я не обладаю достаточными, для написания оного алгоритма (эк ляпнул...)).
(Offline)
 
Ответить с цитированием
Старый 24.03.2010, 18:43   #8
Pyth_ON
Оператор ЭВМ
 
Регистрация: 07.11.2008
Сообщений: 29
Написано 6 полезных сообщений
(для 7 пользователей)
Ответ: Аналог "cmd" на мобиле...

Пинг - ничто инное как ICMP-пакет.
ICMP трафик ходит поверх TCP.
телефоны поддерживают socket-соединения, и позволяют передавать пакеты некоторых протоколов в "сыром" (raw) виде, можно попробовать отправлять ICMP-пакеты...
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
spownc (25.03.2010)
Старый 25.03.2010, 08:04   #9
spownc
AnyKey`щик
 
Регистрация: 15.03.2010
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Хорошо Ответ: Аналог "cmd" на мобиле...

Сообщение от Pyth_ON Посмотреть сообщение
Пинг - ничто инное как ...
Не, без стакана точно не разоберусь))
Ну ладно, хоть что-то.. Спасибо всем!

Тема закрыта.
(Offline)
 
Ответить с цитированием
Старый 25.03.2010, 15:30   #10
_Nox_
ПроЭктировщик
 
Регистрация: 21.06.2009
Адрес: Беларусь, Столбцы
Сообщений: 148
Написано 32 полезных сообщений
(для 57 пользователей)
Ответ: Аналог "cmd" на мобиле...

/*
 * @(#)Ping.java	1.2 01/12/13
 * Connect to each of a list of hosts and measure the time required to complete
 * the connection.  This example uses a selector and two additional threads in
 * order to demonstrate non-blocking connects and the multithreaded use of a
 * selector.
 *
 * Copyright 2001-2002 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or 
 * without modification, are permitted provided that the following 
 * conditions are met:
 * 
 * -Redistributions of source code must retain the above copyright  
 * notice, this  list of conditions and the following disclaimer.
 * 
 * -Redistribution in binary form must reproduct the above copyright 
 * notice, this list of conditions and the following disclaimer in 
 * the documentation and/or other materials provided with the 
 * distribution.
 * 
 * Neither the name of Sun Microsystems, Inc. or the names of 
 * contributors may be used to endorse or promote products derived 
 * from this software without specific prior written permission.
 * 
 * This software is provided "AS IS," without a warranty of any 
 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND 
 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY 
 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY 
 * DAMAGES OR LIABILITIES  SUFFERED BY LICENSEE AS A RESULT OF  OR 
 * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR 
 * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE 
 * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, 
 * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER 
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF 
 * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 * 
 * You acknowledge that Software is not designed, licensed or 
 * intended for use in the design, construction, operation or 
 * maintenance of any nuclear facility. 
 */

import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
import java.util.*;
import java.util.regex.*;


public class Ping {

    // The default daytime port
    static int DAYTIME_PORT = 13;

    // The port we'll actually use
    static int port = DAYTIME_PORT;


    // Representation of a ping target
    // 
    static class Target {

	InetSocketAddress address;
	SocketChannel channel;
	Exception failure;
	long connectStart;
	long connectFinish = 0;
	boolean shown = false;

	Target(String host) {
	    try {
		address = new InetSocketAddress(InetAddress.getByName(host),
						port);
	    } catch (IOException x) {
		failure = x;
	    }
	}

	void show() {
	    String result;
	    if (connectFinish != 0)
		result = Long.toString(connectFinish - connectStart) + "ms";
	    else if (failure != null)
		result = failure.toString();
	    else
		result = "Timed out";
	    System.out.println(address + " : " + result);
	    shown = true;
	}

    }


    // Thread for printing targets as they're heard from
    //
    static class Printer
	extends Thread
    {
	LinkedList pending = new LinkedList();

	Printer() {
	    setName("Printer");
	    setDaemon(true);
	}

	void add(Target t) {
	    synchronized (pending) {
		pending.add(t);
		pending.notify();
	    }
	}

	public void run() {
	    try {
		for (;;) {
		    Target t = null;
		    synchronized (pending) {
			while (pending.size() == 0)
			    pending.wait();
			t = (Target)pending.removeFirst();
		    }
		    t.show();
		}
	    } catch (InterruptedException x) {
		return;
	    }
	}

    }


    // Thread for connecting to all targets in parallel via a single selector
    // 
    static class Connector
	extends Thread
    {
	Selector sel;
	Printer printer;

	// List of pending targets.  We use this list because if we try to
	// register a channel with the selector while the connector thread is
	// blocked in the selector then we will block.
	//
	LinkedList pending = new LinkedList();

	Connector(Printer pr) throws IOException {
	    printer = pr;
	    sel = Selector.open();
	    setName("Connector");
	}

	// Initiate a connection sequence to the given target and add the
	// target to the pending-target list
	//
	void add(Target t) {
	    SocketChannel sc = null;
	    try {

		// Open the channel, set it to non-blocking, initiate connect
		sc = SocketChannel.open();
		sc.configureBlocking(false);

		boolean connected = sc.connect(t.address);

		// Record the time we started
		t.channel = sc;
		t.connectStart = System.currentTimeMillis();

		if (connected) {
		    t.connectFinish = t.connectStart;
		    sc.close();
		    printer.add(t);
		} else {
		    // Add the new channel to the pending list
		    synchronized (pending) {
		        pending.add(t);
		    }

		    // Nudge the selector so that it will process the pending list
		    sel.wakeup();
		}
	    } catch (IOException x) {
		if (sc != null) {
		    try {
			sc.close();
		    } catch (IOException xx) { }
		}
		t.failure = x;
		printer.add(t);
	    }
	}

	// Process any targets in the pending list
	//
	void processPendingTargets() throws IOException {
	    synchronized (pending) {
		while (pending.size() > 0) {
		    Target t = (Target)pending.removeFirst();
		    try {

			// Register the channel with the selector, indicating
			// interest in connection completion and attaching the
			// target object so that we can get the target back
			// after the key is added to the selector's
			// selected-key set
			t.channel.register(sel, SelectionKey.OP_CONNECT, t);

		    } catch (IOException x) {

			// Something went wrong, so close the channel and
			// record the failure
			t.channel.close();
			t.failure = x;
			printer.add(t);

		    }

		}
	    }
	}

	// Process keys that have become selected
	//
	void processSelectedKeys() throws IOException {
	    for (Iterator i = sel.selectedKeys().iterator(); i.hasNext();) {

		// Retrieve the next key and remove it from the set
		SelectionKey sk = (SelectionKey)i.next();
		i.remove();

		// Retrieve the target and the channel
		Target t = (Target)sk.attachment();
		SocketChannel sc = (SocketChannel)sk.channel();

		// Attempt to complete the connection sequence
		try {
		    if (sc.finishConnect()) {
			sk.cancel();
			t.connectFinish = System.currentTimeMillis();
			sc.close();
			printer.add(t);
		    }
		} catch (IOException x) {
		    sc.close();
		    t.failure = x;
		    printer.add(t);
		}
	    }
	}

	volatile boolean shutdown = false;

	// Invoked by the main thread when it's time to shut down
	//
	void shutdown() {
	    shutdown = true;
	    sel.wakeup();
	}

	// Connector loop
	//
	public void run() {
	    for (;;) {
		try {
		    int n = sel.select();
		    if (n > 0)
			processSelectedKeys();
		    processPendingTargets();
		    if (shutdown) {
			sel.close();
			return;
		    }
		} catch (IOException x) {
		    x.printStackTrace();
		}
	    }
	}

    }


    public static void main(String[] args)
	throws InterruptedException, IOException
    {
	if (args.length < 1) {
	    System.err.println("Usage: java Ping [port] host...");
	    return;
	}
	int firstArg = 0;

	// If the first argument is a string of digits then we take that
	// to be the port number to use
	if (Pattern.matches("[0-9]+", args[0])) {
	    port = Integer.parseInt(args[0]);
	    firstArg = 1;
	}

	// Create the threads and start them up
	Printer printer = new Printer();
	printer.start();
	Connector connector = new Connector(printer);
	connector.start();

	// Create the targets and add them to the connector
	LinkedList targets = new LinkedList();
	for (int i = firstArg; i < args.length; i++) {
	    Target t = new Target(args[i]);
	    targets.add(t);
	    connector.add(t);
	}

	// Wait for everything to finish
	Thread.sleep(2000);
	connector.shutdown();
	connector.join();

	// Print status of targets that have not yet been shown
	for (Iterator i = targets.iterator(); i.hasNext();) {
	    Target t = (Target)i.next();
	    if (!t.shown)
		t.show();
	}

    }

}
__________________
(Offline)
 
Ответить с цитированием
Эти 2 пользователя(ей) сказали Спасибо _Nox_ за это полезное сообщение:
PacMan (20.06.2010), Rock2roll (06.08.2010)
Старый 06.08.2010, 13:10   #11
IDOL 1234
ПроЭктировщик
 
Аватар для IDOL 1234
 
Регистрация: 22.11.2009
Сообщений: 137
Написано 8 полезных сообщений
(для 8 пользователей)
Ответ: Аналог "cmd" на мобиле...

в minicommander есть поддержка bat - файлов.
__________________
---
(Offline)
 
Ответить с цитированием
Ответ


Опции темы

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


Часовой пояс GMT +4, время: 09:52.


vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot
Style crйe par Allan - vBulletin-Ressources.com