This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re:Sprintf issue


This sounds more like a sed problem than an sprintf problem.

First, can you get the sed command to work at the cygwin prompt?  If
not, it's quite possible that the environment from which your running
the program does not have sed in its' path.

You should also try this: 

`echo "yada" | sed 's/:/-/g'`

The best solution would be to convert the ':' chars to '-' chars in your
C program.

David




On Mon, 2002-02-18 at 05:25, Jorge Goncalvez wrote:
> Hi, i tried to modified a C program running on linux and make it running on 
> windows with gcc for cygwin:
> like this:
>  sprintf(arpbuf, "arp -s %s `echo %s | sed -e s/:/-/g`"
>          piaddr (lease -> ip_addr),
>          print_hw_addr (lease -> hardware_addr.htype,
>                         lease -> hardware_addr.hlen,
>                         lease -> hardware_addr.haddr));
>  note(arpbuf);
>  system(arpbuf);
> }
> 
> and the original was:
> 
>  sprintf(arpbuf, "arp -s %s  %s ",
>          piaddr (lease -> ip_addr),
>          print_hw_addr (lease -> hardware_addr.htype,
>                         lease -> hardware_addr.hlen,
>                         lease -> hardware_addr.haddr));
>  note(arpbuf);
>  system(arpbuf);
> }
> 
> but my second %s was with the following format XX:XX:XX:XX:XX:XX and i would 
> replace it by XX-XX-XX-XX-XX-XX.
> I tried sed but it didn't work.Why? it seem not to be interpreted I have :
> arp -s 192.40.54.42 `echo 00:80:9f:2e:3f:5e | sed -e s/:/-/g`
> 
> Could i do it in pure C?Thanks for your precious help.
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
-- 

No trees were killed in the sending of this message. However,
a large number of electrons were terribly inconvenienced.

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]