<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; "><div><div><div><div><div><div>I believe c:pid/3 is given to you for convenience of debugging.</div></div></div><div>I don't think there is one that converts list(string) to port, and I also think we do not convert string to port in code.</div><div><br></div><div>since it is shell environment you want to run on, I don't think performance really matters.</div><div>If so, you can use a simple function like this.</div><div><br></div><div><div>PortInfo = fun(Num) -></div><div> [MyPort] =lists:filter(fun(Port) -> {id,PortNum} = erlang:port_info(Port,id), PortNum==Num end, erlang:ports()), </div><div> erlang:port_info(MyPort)</div><div>end.</div></div><div><br></div><div>PortInfo(267).</div></div><div><br></div><div>Allen</div><div><br></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; "><span style="font-weight:bold">From: </span> "Andy W. Song" <<a href="mailto:wsongcn@gmail.com">wsongcn@gmail.com</a>></span></div></span></div></span></div></div></div><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">Date: </span> Wed, 22 Jun 2011 09:07:18 -0500<br><span style="font-weight:bold">To: </span> Allen Kim <<a href="mailto:allen.kim@epicadvertising.com">allen.kim@epicadvertising.com</a>><br><span style="font-weight:bold">Subject: </span> Re: [erlang-questions] Call erlang:port_info/1 from shell<br></div><div><br></div>This is not convenient. I can use pid(0,22222,0) to get a pid from shell. I suppose there should be a similar way for ports. If have thousands of ports, which I do, and I just want to examine one of them from shell, I can't walk through them.<br><br><div class="gmail_quote">2011/6/22 Allen Kim <span dir="ltr"><<a href="mailto:allen.kim@epicadvertising.com">allen.kim@epicadvertising.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word;color:rgb(0, 0, 0);font-size:14px;font-family:Calibri, sans-serif"><div><div><div>[ erlang:port_info(Port) || Port <- erlang:ports()].</div><div><br></div><div>You can also use lists:foreach instead.</div><div><div style="word-wrap:break-word;font-family:Helvetica;font-size:medium"><font face="Calibri, sans-serif"><font face="Helvetica"><br></font></font></div></div></div></div><span><div style="font-family:Calibri;font-size:11pt;text-align:left;color:black;border-bottom:medium none;border-left:medium none;padding-bottom:0in;padding-left:0in;padding-right:0in;border-top:#b5c4df 1pt solid;border-right:medium none;padding-top:3pt"><span style="font-weight:bold">From: </span> "Andy W. Song" <<a href="mailto:wsongcn@gmail.com" target="_blank">wsongcn@gmail.com</a>><br><span style="font-weight:bold">Date: </span> Wed, 22 Jun 2011 08:49:30 -0500<br><span style="font-weight:bold">To: </span> erlang-questions <<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>><br><span style="font-weight:bold">Subject: </span> [erlang-questions] Call erlang:port_info/1 from shell<br></div><div><div></div><div class="h5"><div><br></div>Hi, <div><br></div><div>If I run erlang:ports() from shell, it shows</div><div><div> </div><div>[#Port<0.1>,#Port<0.113>,#Port<0.118>,#Port<0.125>,</div><div> #Port<0.513>,#Port<0.526>,#Port<0.201852>,#Port<0.202767>,</div><div> #Port<0.202768>,#Port<0.202769>,#Port<0.202770>,</div><div> #Port<0.202771>,#Port<0.202772>,#Port<0.202773>,</div><div> #Port<0.202774>,#Port<0.202775>,#Port<0.202776>,</div><div> #Port<0.202777>,#Port<0.202778>,#Port<0.202779>,</div><div> #Port<0.202780>,#Port<0.202781>,#Port<0.202782>,</div><div> #Port<0.202783>,#Port<0.202784>,#Port<0.202785>,</div><div> #Port<0.202786>,#Port<0.202787>,#Port<0.202788>|...]</div><div><br></div><div>Now I want to call erlang:port_info/1, but I don't know how to build the Port() parameter from say #Port<0.513>. Can anybody help? And BTW, where should I look for the document about this kind of thing?</div><div><br></div><div>Thanks</div><div>Andy</div><br>-- <br><div>---------------------------------------------------------------</div><div>有志者,事竟成,破釜沉舟,百二秦关终属楚</div><div>苦心人,天不负,卧薪尝胆,三千越甲可吞吴</div><br></div></div></div></span></div></blockquote></div><br><br clear="all"><br>-- <br><div>---------------------------------------------------------------</div><div>有志者,事竟成,破釜沉舟,百二秦关终属楚</div><div>苦心人,天不负,卧薪尝胆,三千越甲可吞吴</div><br></span></body></html>