如何在同一行连接两个字符串值?

How to concatenate two string values on the same line?

我正在写两个脚本,第一个在 bash 中,第二个在 Python 中。所需的输出是 IP 地址和端口号在同一行上,不带空格,例如

这是bash:

#! /bin/sh
echo $(find /u01/ -name config.xml |grep -v bak| xargs grep -A4 AdminServer | grep listen-address | cut -d'>' -f 2 | cut -d'<' -f 1)

及其输出

172.31.138.15

Python:

import os
import sys
from java.lang import System
import getopt
import time

values = os.popen(str('sh /home/oracle/scripts/wls/adminurl.sh'))
url = str("".join(map(str, values)))
port = ":7001"
adminurl = url + port + "\n"

def connectToDomain():
    try:
        if ServerName != "" or username == "" and password == "" and adminUrl == "":
            print (adminurl)
            connect(userConfigFile='/home/oracle/scripts/wls/userconfig.secure', userKeyFile='/home/oracle/scripts/wls/userkey.secure', url=adminurl, timeout=60000)

[...]

及其输出

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

172.31.138.15
:7001

Connecting to t3://172.31.138.15
:7001
 with userid weblogic ...
This Exception occurred at Fri Jan 10 18:00:22 CET 2020.
javax.naming.ServiceUnavailableException: 172.31.138.15
: unknown error [Root exception is java.net.UnknownHostException: 172.31.138.15
: unknown error]

The domain is unreacheable

我需要将 ip 值与端口值放在同一行,以便将“adminurl”识别为“connect[=34”中的参数=]' 函数。

感谢任何帮助!

adminurl = url.rstrip() + 端口 + "\n"