mac_string = '001485e55503' (This is the mac address of a computer.)
I am using wake on LAN python script to start computer remote.It uses
format like this ....
s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255',
80))
where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.
What I do is break the string into 6 parts like this,
str01=mac_string[0:2]
str02=mac_string[2:4]
str03=mac_string[4:6]
str04=mac_string[6:8]
str05=mac_string[8:10]
str06=mac_string[10:12]
and if I use it like this
s.sendto('\xff'*6 + '\xstr01\xstr02\xstr03\xstr04\xstr05\xstr06'*16,
('192.168.1.255', 80))
I get an error
I also tried like this
s.sendto('\xff'*6 + 'mac_string'*16, ('192.168.1.255', 80))
Thiis also didnt work.
Since the MAC adddress are hexadecimal, how should I go about it here.
Please help, every help is appreciated. Thanks 7 1640 di********@gmail.com wrote: mac_string = '001485e55503' (This is the mac address of a computer.)
I am using wake on LAN python script to start computer remote.It uses format like this ....
s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255', 80))
where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.
s.sendto('\xff'*6 + binascii.unhexlify(mac_string) *16, ('192.168.1.255', 80))
</F> di********@gmail.com wrote: mac_string = '001485e55503' (This is the mac address of a computer.)
I am using wake on LAN python script to start computer remote.It uses format like this ....
s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255', 80))
where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.
What I do is break the string into 6 parts like this,
str01=mac_string[0:2] str02=mac_string[2:4] str03=mac_string[4:6] str04=mac_string[6:8] str05=mac_string[8:10] str06=mac_string[10:12]
and if I use it like this
s.sendto('\xff'*6 + '\xstr01\xstr02\xstr03\xstr04\xstr05\xstr06'*16, ('192.168.1.255', 80)) I get an error
I also tried like this s.sendto('\xff'*6 + 'mac_string'*16, ('192.168.1.255', 80))
Thiis also didnt work.
Since the MAC adddress are hexadecimal, how should I go about it here.
Please help, every help is appreciated. Thanks
See http://docs.python.org/lib/typesseq-strings.html
You probably want:
s.sendto('\xff'*6 + ('\x%s\x%s\x%s\x%s\x%s\x%s' % (str01, str02, str03,
sttr04, str05, str06))*16, ('192.168.1.255', 80))
Iain
Many Thanks!! It worked like a charm.
Fredrik Lundh wrote: di********@gmail.com wrote:
mac_string = '001485e55503' (This is the mac address of a computer.)
I am using wake on LAN python script to start computer remote.It uses format like this ....
s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255', 80))
where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.
s.sendto('\xff'*6 + binascii.unhexlify(mac_string) *16, ('192.168.1.255', 80))
</F>
I will try this one too...thanks for your response.
Iain King wrote: di********@gmail.com wrote: mac_string = '001485e55503' (This is the mac address of a computer.)
I am using wake on LAN python script to start computer remote.It uses format like this ....
s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255', 80))
where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.
What I do is break the string into 6 parts like this,
str01=mac_string[0:2] str02=mac_string[2:4] str03=mac_string[4:6] str04=mac_string[6:8] str05=mac_string[8:10] str06=mac_string[10:12]
and if I use it like this
s.sendto('\xff'*6 + '\xstr01\xstr02\xstr03\xstr04\xstr05\xstr06'*16, ('192.168.1.255', 80)) I get an error
I also tried like this s.sendto('\xff'*6 + 'mac_string'*16, ('192.168.1.255', 80))
Thiis also didnt work.
Since the MAC adddress are hexadecimal, how should I go about it here.
Please help, every help is appreciated. Thanks
See http://docs.python.org/lib/typesseq-strings.html
You probably want:
s.sendto('\xff'*6 + ('\x%s\x%s\x%s\x%s\x%s\x%s' % (str01, str02, str03, sttr04, str05, str06))*16, ('192.168.1.255', 80))
Iain di********@gmail.com wrote: mac_string = '001485e55503' (This is the mac address of a computer.) Since the MAC adddress are hexadecimal, how should I go about it here.
Please help, every help is appreciated. Thanks
I could not quite understand what you are trying to achieve, but
it appears that you want to convert a character strings of hexadecimal
characters into a byte string with the same bytes. I recommend this:
py> import binascii
py> binascii.a2b_hex("001485e55503")
'\x00\x14\x85\xe5U\x03'
Of course, if the string is fixed, you could just as well use the
result string (i.e. '\x00\x14\x85\xe5U\x03') directly.
Regards,
Martin
"Iain King" <ia******@gmail.com> wrote: You probably want:
s.sendto('\xff'*6 + ('\x%s\x%s\x%s\x%s\x%s\x%s' % (str01, str02, str03, sttr04, str05, str06))*16, ('192.168.1.255', 80))
You probably should TRY suggestions before you post them. That will get an
"invalid \x escape". \x must be followed by exactly two hex digits. You
can't build up an escape sequence like this.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts wrote: "Iain King" <ia******@gmail.com> wrote: You probably want:
s.sendto('\xff'*6 + ('\x%s\x%s\x%s\x%s\x%s\x%s' % (str01, str02, str03, sttr04, str05, str06))*16, ('192.168.1.255', 80))
You probably should TRY suggestions before you post them. That will get an "invalid \x escape". \x must be followed by exactly two hex digits. You can't build up an escape sequence like this. -- - Tim Roberts, ti**@probo.com Providenza & Boekelheide, Inc.
You're right. I'd foolishly assumed that \x was just another character
code, like \t or \n. Apologies.
Iain This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sparks |
last post by:
I know this is a stupid question but I can't find the answer.
Please tell me where to find reference to this so I can print it out
and staple it to my head..
dim I as integer
dim missedstr as...
|
by: John Baro |
last post by:
I have a richtextbox which I want the "literal" rtf of.
richtextbox.rtf returns
{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0
when i put this into a string I get...
|
by: Dave |
last post by:
I'm receiving info from a com port into a string. I gradually process the
string which constantly shortens it. The question is how long can a string be
before I need to write some info to disk...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: Dan Schumm |
last post by:
I'm relatively new to regular expressions and was looking for some help on a
problem that I need to solve. Basically, given an HTML string, I need to
highlight certain words within the text of the...
| |
by: Zordiac |
last post by:
How do I dynamically populate a string array?
I hope there is something obvious that I'm missing here
Option Strict On
dim s() as string
dim sTmp as string = "test"
dim i as integer
...
|
by: Jeff |
last post by:
In the function below, can size ever be 0 (zero)?
char *clc_strdup(const char * CLC_RESTRICT s)
{
size_t size;
char *p;
clc_assert_not_null(clc_strdup, s);
size = strlen(s) + 1;
|
by: tommaso.gastaldi |
last post by:
Hi,
does anybody know a speedy analog of IsNumeric() to check for
strings/chars. I would like to check if an Object can be treated as a
string before using a Cstr(), clearly avoiding the time...
|
by: sucaba.r |
last post by:
I don't know if this is a unique problem, or I'm going about it the
wrong way. I currently connect to one of our SQL servers via a
priviliged account (by using RUNAS). Works with no problem. I...
|
by: Sky |
last post by:
I have been looking for a more powerful version of GetType(string) that will
find the Type no matter what, and will work even if only supplied
"{TypeName}", not the full "{TypeName},{AssemblyName}"...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |