首页 > others > MAC下修改被HP打印机占用的8080端口

MAC下修改被HP打印机占用的8080端口

2013年12月10日

Mac的8080端口被占了,查了一下是 HP printer agent 占用了8080端口,这是Tomcat, JBoss and others servlet engines/application servers 的默认端口。于是先干掉这个端口。

$ netstat -na|grep 8080
tcp6       0      0  *.8080                 *.*                    LISTEN     
tcp4       0      0  *.8080                 *.*                    LISTEN  
$ lsof -i:8080
COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd    274   u2    9u  IPv4 0x4c7c1dc47078aa3d      0t0  TCP *:http-alt (LISTEN)
launchd    274   u2   10u  IPv6 0x4c7c1dc46f0555f5      0t0  TCP *:http-alt (LISTEN)
printerAg 2052   u2    5u  IPv4 0x4c7c1dc47078aa3d      0t0  TCP *:http-alt (LISTEN)
printerAg 2052   u2    6u  IPv6 0x4c7c1dc46f0555f5      0t0  TCP *:http-alt (LISTEN)

kill -9 401
kill之后会自动重启一个新的进程,8080端口依然健在,汗一个!


$ lsof -i:8080
COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd    274   u2    9u  IPv4 0x4c7c1dc47078aa3d      0t0  TCP *:http-alt (LISTEN)
launchd    274   u2   10u  IPv6 0x4c7c1dc46f0555f5      0t0  TCP *:http-alt (LISTEN)
printerAg 2052   u2    5u  IPv4 0x4c7c1dc47078aa3d      0t0  TCP *:http-alt (LISTEN)
printerAg 2052   u2    6u  IPv6 0x4c7c1dc46f0555f5      0t0  TCP *:http-alt (LISTEN)

难道要妥协? 修改tomcat默认端口从8080到其他端口(8081),太没面子了。

$ cat ~/Library/LaunchAgents/com.hp.printerAgent.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.hp.printerAgent</string>
	<key>OnDemand</key>
	<false/>
	<key>Program</key>
	<string>/Library/Printers/hp/laserjet/P1100_1560_1600Series/printerAgent</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Library/Printers/hp/laserjet/P1100_1560_1600Series/printerAgent</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>ServiceIPC</key>
	<true/>
	<key>Sockets</key>
	<dict>
		<key>MyListenerSocket</key>
		<dict>
			<key>SockServiceName</key>
			<string>8080</string>
		</dict>
	</dict>
</dict>
</plist>

或者
sudo sed -i “” -e “s|8080|18089|g” ~/Library/LaunchAgents/com.hp.printerAgent.plist

重启mac,下面就是见证奇迹的时刻~,enjoy it 🙂

分类: others 标签:
本文的评论功能被关闭了.