AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-182280

gatorback's questions

Martin Hope
gatorback
Asked: 2025-04-08 13:39:26 +0800 CST

如何设置 duckdns 证书

  • 4

用户@nextcloudpi:/$sudo certbot -d downwind.duckdns.org --manual --preferred-challenges dns certonly~

返回:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.downwind.duckdns.org with the following value:

to8BGF9LfNEOTdZkJAMUYoEd0rROw8Zwa6dumWVBIvA

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

因为我正在尝试为 duckdns 设置证书,所以我尝试了:

https://www.duckdns.org/update?domains=downwind.duckdns.org&token=MyDuckdnsToken&txt=to8BGF9LfNEOTdZkJAMUYoEd0rROw8Zwa6dumWVBIvA

我想验证证书是否有效。有没有可以远程执行的命令行测试?

更新

SSL 检查器返回:

在此处输入图片描述

结果是否表明证书安装成功?

dns
  • 1 个回答
  • 27 Views
Martin Hope
gatorback
Asked: 2025-04-06 13:53:01 +0800 CST

如何从 MacOS/Safari 排除 duckDNS 故障

  • 5

NCP(nextcloudpi)服务器位于 myfqdn.duckdns.org

Safari 返回:

在此处输入图片描述

Chrome 返回:

在此处输入图片描述

私人 Safari 浏览器返回预期的 NCP 网页。

我寻求一个故障排除程序来诊断问题:我想知道是否存在证书问题。

networking
  • 1 个回答
  • 28 Views
Martin Hope
gatorback
Asked: 2025-01-09 01:39:12 +0800 CST

SSH 服务器状态显示已禁用

  • 8

上下文: Raspberry pi 3B+ 上的 64 位 Ubuntu Server 24.04

sudo systemctl 状态 ssh

重启 ssh 服务器后的结果。为什么第二行显示已禁用?如何诊断/测试?这会带来什么限制?

● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/usr/lib/systemd/system/ssh.service; disabled; preset: enabled)
     Active: active (running) since Wed 2025-01-08 07:35:43 UTC; 8h ago
TriggeredBy: ● ssh.socket
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 1584 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 1586 (sshd)
      Tasks: 1 (limit: 853)
     Memory: 1.1M (peak: 2.9M)
        CPU: 303ms
     CGroup: /system.slice/ssh.service
             └─1586 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Jan 08 07:35:43 rpi3mqtt systemd[1]: Starting ssh.service - OpenBSD Secure Shell server...
Jan 08 07:35:43 rpi3mqtt sshd[1586]: Server listening on :: port 22.
Jan 08 07:35:43 rpi3mqtt systemd[1]: Started ssh.service - OpenBSD Secure Shell server.
Jan 08 14:48:16 rpi3mqtt sshd[2411]: Connection closed by authenticating user ubuntu 192.168.8.242 port 64789 [preauth]

根据评论的要求:

sudo systemctl status ssh.socket

● ssh.socket - OpenBSD Secure Shell server socket
     Loaded: loaded (/usr/lib/systemd/system/ssh.socket; enabled; preset: enabled)
     Active: active (running) since Wed 2025-01-08 19:03:57 UTC; 2h 36min ago
   Triggers: ● ssh.service
     Listen: [::]:22 (Stream)
      Tasks: 0 (limit: 853)
     Memory: 8.0K (peak: 256.0K)
        CPU: 3ms
     CGroup: /system.slice/ssh.socket

Jan 08 19:03:57 rpi3mqtt systemd[1]: Listening on ssh.socket - OpenBSD Secure Shell server socket.
ubuntu
  • 1 个回答
  • 366 Views
Martin Hope
gatorback
Asked: 2024-08-10 20:14:15 +0800 CST

应用程序依赖关系的命名法

  • 5

假设此命令从 MacOS 终端命令行调用一个应用程序:

/Applications/Matlab_R2020a.app/bin/matlab

然后终端不再能够接受命令,MATLAB 是依赖的(即如果终端控制台关闭,MATLAB 将终止)。这种依赖关系叫什么?如何启动应用程序才能使其“独立”?也就是说,关闭终端不会关闭应用程序?

macos
  • 2 个回答
  • 39 Views
Martin Hope
gatorback
Asked: 2023-11-05 00:24:40 +0800 CST

错误:通过不受信任的域访问

  • 5

NexctcloudPi (Raspbian\Debian) 安装在 USB-SSD 上的 rpi3 上。

初步测试成功。访问方式:

  • 鸭子域名
  • 让我们加密证书

初始设置后成功。

系统已重新启动,现在返回:

在此输入图像描述

可以使用哪些 Debian 命令来探测和测试以确定问题的根本原因?

感谢对错误的简单(ELI5)解释:谢谢

raspbian
  • 1 个回答
  • 17 Views
Martin Hope
gatorback
Asked: 2021-11-21 15:41:26 +0800 CST

zsh 不区分大小写的通配符

  • 1

上下文:macOS Catalina (zsh)

此脚本用于处理所有 JPEG 文件。此脚本不处理 .JPG 文件,但它确实处理 .jpg 文件。

top=/Users/user/Desktop/
for file in $top/**/*.jp*g(NDn.); do      #selects filetypes: .jpg .jpeg 
  mogrify -auto-orient \
          -gravity northWest \
          -font "Arial-Bold-Italic" \
          -pointsize 175 \
          -fill red \
          -annotate +30+30 $n \
          -- $file &&
  echo  $file "was watermarked with" $n | tee -a forLooplog.txt
  (( n++ ))
done

如何将第二行修改为不区分大小写并捕获 .JPG .JPEG 文件?

zsh wildcards
  • 1 个回答
  • 407 Views
Martin Hope
gatorback
Asked: 2021-11-20 21:28:53 +0800 CST

如何在 -exec 脚本中增加 COUNTER?

  • 4

上下文:zsh Catalina MacOS:

可执行脚本BatesStamp 使用imagemagick 将数字标记到 jpg 文件中:

# BatesStamp: OVERWRITES and stamps ONE file with COUNTER  (upper left corner)
# usage  ./BatesStamp  COUNTER  PATH_FILE   
# to be used with find & -exec: https://unix.stackexchange.com/a/96239/182280   


COUNTER=$1     # 1st argument = number to be stamped upon .jpg file
PATH_FILE=$2   # 2nd argument = /path_to_file/Filename.jpg

convert $PATH_FILE  -auto-orient -gravity northWest  -font "Arial-Bold-Italic" -pointsize 175 \
   -fill red  -annotate +30+30   "$COUNTER"  $PATH_FILE;
   ((COUNTER++))  #https://stackoverflow.com/a/21035146/4953146
   echo "watermarked i= $COUNTER  $PATH_FILE"

目标是用唯一编号标记目录树中的所有 .jpg 文件。我相信每次调用 $COUNTER 时都必须增加它:这确保每个文件都带有唯一的编号。该策略是遍历所有子目录find以识别 .jpg 文件,并使用 $COUNTER++ 对每个 .jpg 文件进行 BatesStamp。

此脚本goBatesStamp.sh遍历子目录以执行每个要由BatesStamp处理的 .jpg 文件

# goBastesStamp.sh
cd /Users/user/Desktop/AITH_USB_Hope_Submitted_MyCloud/PhotoGraphs_Work/A_Building_NoBulkhead. # navigate to top level directory
COUNTER=100   # initialize COUNTER
find /Users/user/Desktop/AITH_USB_Hope_Submitted_MyCloud/PhotoGraphs_Work/A_Building_NoBulkhead -iname "*.jpg" -exec ./BatesStamp $((COUNTER+=1)) {} \;  

问题在于以命令开头的行find。具体来说, COUNTER 不会增加。

测试表明 .jpg 文件标有数字 100 它表明 $((COUNTER++)) 是问题所在。将 COUNTER 递增 1 并将递增的 COUNTER 输入 ./BatesStamp 的正确语法是什么?

shell-script find
  • 1 个回答
  • 260 Views
Martin Hope
gatorback
Asked: 2020-02-03 11:14:03 +0800 CST

可以对 SD 卡映像文件执行 zerofree 处理吗?

  • 1

在此处输入图像描述

Ubuntu 16.04:使用以下命令创建了 64GB SD 卡映像:

date; sudo sh -c 'pv /dev/mmcblk0 >rpi4_Ubuntu18.1_64GB.image'; date

rasbperry pi SD 卡配备 Ubuntu 18.1

Ubuntu 16.04 笔记本电脑可以:

  • 挂载 .image 文件?
  • 在 .image 文件的挂载点上运行 zerofree?
  • 卸载 .image 文件?

我知道可以将图像文件恢复到 SD 卡并使用zerofree处理卡并再次捕捉图像。如果能够在不将它们恢复到 SD 卡的情况下处理多个 .image 文件,那就太好了。

更新:测试结果

映像成功挂载到 /dev/loop9p2:

$ sudo losetup -P /dev/loop9 rpi4_Ubuntu18.1_64GB.image
$ ls -l /dev/loop9*
brw-rw---- 1 root disk   7, 9 Feb  2 19:12 /dev/loop9
brw-rw---- 1 root disk 259, 0 Feb  2 19:12 /dev/loop9p1
brw-rw---- 1 root disk 259, 1 Feb  2 19:12 /dev/loop9p2

零故障:

$ zerofree -v /dev/loop9p2
zerofree: failed to open filesystem /dev/loop9p2

需要零零sudo:

$ sudo zerofree -v /dev/loop9p2
14346339/14348998/15073019
  • 14346339 遇到的非零块数
  • 14348998 文件系统中的空闲块数
  • 15073019 文件系统内的总块数

奖励:使用脚本pishrink减小图像大小

sd-card disk-image
  • 1 个回答
  • 737 Views
Martin Hope
gatorback
Asked: 2020-02-03 06:08:57 +0800 CST

最小 SD 卡映像

  • 1

如果要复制 SD 卡的命令:

date; sudo sh -c 'pv /dev/mmcblk0 >pv sdcard.image'; date

将全新安装的 Raspbian 安装在 128GB SD 卡上,然后 sdcard.image 文件将是 128GB。假设全新安装 Raspbian 需要 10 GB 空间。大多数图像将不包含数据(“空白空间”)。如果生成的图像:

  1. 尺寸最小(在任何压缩之前,而不是复制“空白空间”)
  2. 可以安装到minimal SD-Card (16GB SD 卡或更大)

容量是可以接受全新安装 Raspbian的minimal SD-card最小 SD 卡:因为没有 10GB 的 SD 卡,所以下一个更大的尺寸(16GB)被定义为最小的 SD 卡。

解决方案首选项是为了简单和标准的 Unix 命令(必要时使用脚本)。

2个目标如何实现?一个明智的策略是确定 SD 卡上的数据量(10GB)并将磁盘参数更改为略大于 10GB 的磁盘大小:在这种情况下为 16GB?

参考:

  • 备份 SD 卡会生成一个巨大的 .img 文件
  • PiShrink:BASH 脚本
  • zerofree命令归零可用空间
backup raspberry-pi
  • 1 个回答
  • 233 Views
Martin Hope
gatorback
Asked: 2020-01-21 17:21:58 +0800 CST

转换说明符中的空格字符

  • -1
NOW=$(date +%Y_%m_%d.%H:%M:%S)
echo "NOW: $NOW"

目标是用空格替换and.之间的字符。这是如何执行的?用空格字符替换会产生错误。d%.

string
  • 1 个回答
  • 17 Views
Martin Hope
gatorback
Asked: 2019-08-07 12:50:24 +0800 CST

MQTT 错误:连接丢失

  • 3

设置了“侦听器”控制台:

mosquitto_sub -h test.mosquitto.org -t "myTopic" -v

mosquitto_pub返回错误:

pi@raspberrypi:~ $ mosquitto_pub -h test.mosquitto.org  -t 'myTopic' -m 'hello world'
**Error: The connection was lost.**

可以从命令行采取哪些步骤来诊断是否存在语法问题?

更新:

将 MQTT 服务器替换为iot.eclipse.org不会出现错误并按预期返回有效负载。

侦听器控制台设置:

mosquitto_sub -h iot.eclipse.org -t "myTopic" -v

发送有效载荷:

mosquitto_pub -h iot.eclipse.org -t 'myTopic' -m 'hello world'

mosquitto_pub返回:

pi@raspberrypi:~ $ mosquitto_sub -h iot.eclipse.org -t "myTopic" -v
myTopic hello world

发布有效载荷:

pi@raspberrypi:~ $ mosquitto_pub -h test.mosquitto.org  -t 'myTopic' -m 'hello world'

更改 MQTT 代理表明没有语法错误,但是问题仍然是为什么在原始测试中返回错误

mqtt
  • 2 个回答
  • 4912 Views
Martin Hope
gatorback
Asked: 2019-08-01 20:06:26 +0800 CST

mosquitto_sub –d –t armtronix_mqtt 错误:未知选项“–d”

  • 1

可以收集哪些信息以采取纠正措施以启用对示例 MQTT 主题的订阅?

目标是按照 说明的第 3 步重现测试(订阅和发布) :安装了 MQTT 服务器,但尝试使用 MQTT 客户端订阅失败:

pi@raspberrypi:~ $ mosquitto_sub –d –t armtronix_mqtt

**Error: Unknown option '–d'.**

Use 'mosquitto_sub --help' to see usage.

帮助页面:

pi@raspberrypi:~ $ mosquitto_sub --help
mosquitto_sub is a simple mqtt client that will subscribe to a single topic and print all messages it receives.
mosquitto_sub version 1.4.10 running on libmosquitto 1.4.10.

Usage: mosquitto_sub [-c] [-h host] [-k keepalive] [-p port] [-q qos] [-R] -t topic ...
                     [-C msg_count] [-T filter_out]
                     [-A bind_address] [-S]
                     [-i id] [-I id_prefix]
                     [-d] [-N] [--quiet] [-v]
                     [-u username [-P password]]
                     [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]
                     [{--cafile file | --capath dir} [--cert file] [--key file]
                      [--ciphers ciphers] [--insecure]]
                     [--psk hex-key --psk-identity identity [--ciphers ciphers]]
                     [--proxy socks-url]
       mosquitto_sub --help

 -A : bind the outgoing socket to this host/ip address. Use to control which interface
      the client communicates over.
 -c : disable 'clean session' (store subscription and pending messages when client disconnects).
 -C : disconnect and exit after receiving the 'msg_count' messages.
 -d : enable debug messages.
 -h : mqtt host to connect to. Defaults to localhost.
 -i : id to use for this client. Defaults to mosquitto_sub_ appended with the process id.
 -I : define the client id as id_prefix appended with the process id. Useful for when the
      broker is using the clientid_prefixes option.
 -k : keep alive in seconds for this client. Defaults to 60.
 -N : do not add an end of line character when printing the payload.
 -p : network port to connect to. Defaults to 1883.
 -P : provide a password (requires MQTT 3.1 broker)
 -q : quality of service level to use for the subscription. Defaults to 0.
 -R : do not print stale messages (those with retain set).
 -S : use SRV lookups to determine which host to connect to.
 -t : mqtt topic to subscribe to. May be repeated multiple times.
 -T : topic string to filter out of results. May be repeated.
 -u : provide a username (requires MQTT 3.1 broker)
 -v : print published messages verbosely.
 -V : specify the version of the MQTT protocol to use when connecting.
      Can be mqttv31 or mqttv311. Defaults to mqttv31.
 --help : display this message.
 --quiet : don't print error messages.
 --will-payload : payload for the client Will, which is sent by the broker in case of
                  unexpected disconnection. If not given and will-topic is set, a zero
                  length message will be sent.
 --will-qos : QoS level for the client Will.
 --will-retain : if given, make the client Will retained.
 --will-topic : the topic on which to publish the client Will.
 --cafile : path to a file containing trusted CA certificates to enable encrypted
            certificate based communication.
 --capath : path to a directory containing trusted CA certificates to enable encrypted
            communication.
 --cert : client certificate for authentication, if required by server.
 --key : client private key for authentication, if required by server.
 --ciphers : openssl compatible list of TLS ciphers to support.
 --tls-version : TLS protocol version, can be one of tlsv1.2 tlsv1.1 or tlsv1.
                 Defaults to tlsv1.2 if available.
 --insecure : do not check that the server certificate hostname matches the remote
              hostname. Using this option means that you cannot be sure that the
              remote host is the server you wish to connect to and so is insecure.
              Do not use this option in a production environment.
 --psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.
 --psk-identity : client identity string for TLS-PSK mode.
 --proxy : SOCKS5 proxy URL of the form:
           socks5h://[username[:password]@]hostname[:port]
           Only "none" and "username" authentication is supported.

MQTT 客户端安装日志:

pi@raspberrypi:~ $ sudo apt-get install mosquitto-clients
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  coinor-libipopt1v5 libmumps-seq-4.10.0 libraw15
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libmosquitto1
The following NEW packages will be installed:
  libmosquitto1 mosquitto-clients
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 99.5 kB of archives.
After this operation, 222 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libmosquitto1 armhf 1.4.10-3+deb9u4 [47.2 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian stretch/main armhf mosquitto-clients armhf 1.4.10-3+deb9u4 [52.3 kB]
Fetched 99.5 kB in 1s (86.7 kB/s)           
Selecting previously unselected package libmosquitto1:armhf.
(Reading database ... 141867 files and directories currently installed.)
Preparing to unpack .../libmosquitto1_1.4.10-3+deb9u4_armhf.deb ...
Unpacking libmosquitto1:armhf (1.4.10-3+deb9u4) ...
Selecting previously unselected package mosquitto-clients.
Preparing to unpack .../mosquitto-clients_1.4.10-3+deb9u4_armhf.deb ...
Unpacking mosquitto-clients (1.4.10-3+deb9u4) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libmosquitto1:armhf (1.4.10-3+deb9u4) ...
Setting up mosquitto-clients (1.4.10-3+deb9u4) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...

.listRaspbian buster 的文件安装:

pi@raspberrypi:~ $ cd /etc/apt/sources.list.d/
pi@raspberrypi:/etc/apt/sources.list.d $ sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list
--2019-08-01 00:01:16--  http://repo.mosquitto.org/debian/mosquitto-buster.list
Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2
Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [application/octet-stream]
Saving to: ‘mosquitto-buster.list’

mosquitto-buster.list               100%[===================================================================>]      50  --.-KB/s    in 0s      

2019-08-01 00:01:17 (1.14 MB/s) - ‘mosquitto-buster.list’ saved [50/50]

pi@raspberrypi:/etc/apt/sources.list.d $ mosquitto_sub –t armtronix_mqtt
Error: Unknown option '–t'.

Use 'mosquitto_sub --help' to see usage.
pi@raspberrypi:/etc/apt/sources.list.d $ sudo apt-get install mosquitto-clients
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mosquitto-clients is already the newest version (1.4.10-3+deb9u4).
The following packages were automatically installed and are no longer required:
  coinor-libipopt1v5 libmumps-seq-4.10.0 libraw15
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
pi@raspberrypi:/etc/apt/sources.list.d $ mosquitto_sub –t armtronix_mqtt
Error: Unknown option '–t'.

Use 'mosquitto_sub --help' to see usage.
pi@raspberrypi:/etc/apt/sources.list.d $ mosquitto_sub -d –t  armtronix_mqtt
Error: Unknown option '–t'.

Use 'mosquitto_sub --help' to see usage.
software-installation raspberry-pi
  • 1 个回答
  • 1324 Views
Martin Hope
gatorback
Asked: 2019-06-01 03:36:30 +0800 CST

复制 SD 卡

  • 3

背景

已为 Raspberry pi 配置了 SD 卡。目标是完全复制 SD 卡(操作系统、应用程序、数据),以便副本在 rPi 中的功能与原始\主 SD 卡完全相同。

更新:假设:

  • 复制将在配置有类似 UNIX 操作系统的笔记本电脑上执行
  • 不应从 rPi 执行复制
  • 目标 SD 卡的品牌/型号相同
  • 源 SD 卡使用不同的文件系统进行分区:

在此处输入图像描述

问题

哪些 UNIX 克隆选项适用于带有 SD 卡插槽和 USB SD 卡读卡器/写卡器的 Ubuntu HP 笔记本电脑。

USB SD卡RW是读卡器还是写卡器有区别吗?

一个目标(约束)是避免购买额外的硬件。

解决方案观察

date; sudo sh -c 'cat sdcard.image >/dev/mmcblk0'; date

2019 年 6 月 3 日星期一 17:53:18 EDT [sudo] 用户密码:2019 年 6 月 3 日星期一 23:42:17 EDT

date; sudo sh -c 'pv sdcard.image >/dev/mmcblk0'; date

2019 年 6 月 4 日星期二 00:33:50 EDT [sudo] 用户密码:119GiB 6:06:12 [5.56MiB/s] [=================== ============>] 100%
2019 年 6 月 4 日星期二 06:43:05 EDT

对闪存 SD 卡的 gParted 分析显示相同的分区:

在此处输入图像描述

macOS\OSX

要查找 SD 卡的位置:

diskutil list

写入时请务必卸载 SD 卡:

sudo diskutil unmount /dev/disk#

其中 # 是 1,2,3...

storage sd-card
  • 2 个回答
  • 3682 Views
Martin Hope
gatorback
Asked: 2018-07-23 15:54:08 +0800 CST

为什么将输出重定向到文件会生成表?

  • 0

我想设置一个 cron 作业来定期记录测量值。USB记忆棒安装在路由器中:

user@router:/tmp/home/root# uname -a

Linux 路由器 2.6.36.4brcmarm #2 SMP PREEMPT Sun Mar 20 16:06:18 EDT 2016 armv7l GNU/Linux

user@router:/tmp/home/root# curl http://THERMOSTAT/tstat/humidity  >> /tmp/mnt/USBstick/CT80_data/C14HumidityData.txt

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    18    0    18    0     0     80      0 --:--:-- --:--:-- --:--:--    83

为什么将输出附加(>>)到文件会产生上表?

不附加时不生成该表:

curl http://THERMOSTAT/tstat/humidity
{"humidity":51.00}

是否有抑制表响应的命令选项?

pipe io-redirection
  • 1 个回答
  • 42 Views
Martin Hope
gatorback
Asked: 2018-05-08 13:06:09 +0800 CST

MATLAB 中的 UNIX 纪元时间验证

  • 0

我正在测试 MATLAB 以确保我正确地应用了它的功能。 来自数据源的示例包括:

  • 当前时间(以 UNIX 纪元秒为单位)为:1160967053
  • 纽约当前时间是 Sun Oct 15 22:50:53 EDT 2006

我假设以上是正确的,并试图在 MATLAB 中重现结果:

dt = 日期时间(1160967053,'ConvertFrom','posixtime')

返回:

 dt = 16-Oct-2006 02:50:53

这个结果是 +4 小时:我期待 +5 小时。纽约时间是UTC -5。有1小时的差异:夏令时?

将时区添加到函数时,结果与参考示例匹配:

T = datetime(1160967053,'ConvertFrom','posixtime','TimeZone','America/New_York')

 T = 15-Oct-2006 22:50:53

问题

  • 如果 NYC 是 UTC -5,为什么相差 4 小时?
timezone matlab
  • 1 个回答
  • 616 Views
Martin Hope
gatorback
Asked: 2018-05-06 12:23:41 +0800 CST

将文件列表从 grep 命令复制到目标目录 [重复]

  • -1
这个问题在这里已经有了答案:
Grep 文件中的单词然后复制文件 4 个答案
4年前关闭。

命令:

grep -rl "KORD" ./

搜索目录并返回文件内容(不是标题)中包含“KORD”的文件列表。

Users-MacBook-Air:myPhotorec user$ grep -rl "KORD" ./
.//output_apikey.txt
.//recup_dir.17/f13470392.txt
.//recup_dir.49/f45361992.txt
.//recup_dir.49/f45362424.txt
.//recup_dir.53/f48768408.txt
.//recup_dir.53/f49295480.txt

是否有一个首选命令(xargs?)可以扩充 grep 命令以将输出文件列表打印到控制台并将每个文件复制到 a 目录: ./ORD ?

我怀疑“给猫剥皮”的方法不止一种:我期待看到不止一种解决方案

JOHN1024 的 XARGS 解决方案

重复标签阻止将此修改后的帖子作为答案发布:

尝试:

grep -rl --null --include '*.txt' KORD . | xargs -0r cp -t /path/to/dest

因为此命令使用 NUL 分隔,所以它对于所有文件名都是安全的,包括那些包含空格、制表符甚至换行符的难命名的文件名。

以上需要 GNU cp。对于 BSD/OSX,请尝试:

grep -rl --null --include '*.txt' KORD . | xargs -0 sh -c 'cp "$@" /path/to/dest' sh

这个怎么运作:

  1. grep选项和参数

    • -r告诉 grep 递归搜索目录结构。(在 FreeBSD 上,-r将跟随符号链接进入目录。对于 OS/X 或最新版本的 GNU 都不是这样grep。)

    • --include '*.txt'告诉 grep 仅返回名称与 glob 匹配的文件*.txt(包括隐藏的文件,如.foo.txtor .txt)。

    • -l告诉 grep 只返回匹配文件的名称,而不是匹配项本身。

    • --null告诉 grep 使用 NUL 字符来分隔文件名。

    • LINUX/UNIX告诉 grep 只查找内容包含正则表达式的文件LINUX/UNIX

    • .在当前目录中搜索。您可以在最新版本的 GNU 中省略它grep,但是您需要传递一个--选项终止符来cp防止以 . 开头的文件名-。

  2. xargs选项和参数

    • -0告诉 xargs 期待 NUL 分隔的输入。

    • -r告诉 xargs 除非找到至少一个文件,否则不要运行该命令。(此选项在 BSD 或 OSX 上都不需要,并且与 OSX 的xargs.)不兼容。)

    • cp -t /path/to/dest将目录复制到目标目录。(-t需要 GNU cp。)

grep
  • 1 个回答
  • 3213 Views
Martin Hope
gatorback
Asked: 2018-03-12 17:40:16 +0800 CST

WD MyCloud NFS 挂载到华硕 Merlin 路由器:NFS 挂载故障排除:“没有这样的设备”

  • 2

目标:将 UNIX NAS ( WD myCloud ) 安装到 UNIX 路由器。

已经做了什么(不要假设它是正确的):

  1. 检查路由器正在运行 NFS 客户端:

    ps | grep nfsd 
    

    19243 用户名 1376 R grep nfsd

  2. 检查 NAS 正在从 macbook 运行 NFS 服务器:

    rpcinfo -T udp 192.168.X.XXX | grep nfs
       100003       2     tcp      0.0.0.0.8.1          nfs        unknown
       100003       3     tcp      0.0.0.0.8.1          nfs        unknown
       100003       2     udp      0.0.0.0.8.1          nfs        unknown
       100003       3     udp      0.0.0.0.8.1          nfs        unknown
    
  3. 尝试挂载 NAS 目录使用语法:

    mount -t nfs server_IP_addr:/share_name /local_mount_point

    mount -t NFS 192.168.X.XXX:/shares/Public/Data /mnt/nas
    

    错误响应:

mount:在 /mnt/nas 上安装 192.168.X.XXX:/shares/Public/Data/ 失败: 没有这样的设备

我有兴趣了解如何诊断“没有这样的设备”的原因。是否有系统地解决问题的程序(一系列命令行测试)?

更新/对问题/请求的详细回复:

未找到 nfs 服务器模块且无法加载:

root@WDMyCloud root # service nfs status
-sh: service: not found
root@WDMyCloud root # systemctl status nfs-server
-sh: systemctl: not found
root@WDMyCloud root # lsmod | grep nfs
root@WDMyCloud root # modprobe nfs
modprobe: chdir(/lib/modules): No such file or directory   
root@WDMyCloud root # ipkg
-sh: ipkg: **not found**

ps命令:

root@WDMyCloud root # ps | grep -i nfs
  375 root         0 SW<  [nfsiod]
 2813 root         0 SW   [nfsd]
 2814 root         0 SW   [nfsd]
 2815 root         0 SW   [nfsd]
 2816 root         0 SW   [nfsd]
 2817 root         0 SW   [nfsd]
 2818 root         0 SW   [nfsd]
 2819 root         0 SW   [nfsd]
 2820 root         0 SW   [nfsd]
11491 root      2592 S    grep -i nfs

showmount -e 192.168.X.X 返回一个空的导出列表

nfs troubleshooting
  • 1 个回答
  • 2367 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve