我创建了一个小脚本来在 Nautilus 中添加书签,以将用户重定向到网络共享。如果我手动运行该脚本,它运行得非常好,但是一旦我尝试将其添加到 /etc/profile.d 中,我就无法连接到计算机。似乎只要我执行一个循环或任何类似的“花哨”的事情,脚本就会出错。这是我当前正在工作的脚本的示例:
#!/bin/bash
# Creating gtk-bookmarks if it doesn't exists
if [[ ! -f ~/.gtk-bookmarks ]]
then
touch ~/.gtk-bookmarks
fi
# Adding bookmarks if not present
if ! grep -Fxq "smb://example.com/R03C01 Software:" ~/.gtk-bookmarks
then
echo "smb://example.com/R03C01 Software:" >> ~/.gtk-bookmarks
fi
Run Code Online (Sandbox Code Playgroud)
一旦我有了这样的功能:
####
# Function find_server_by_ip()
# Desc : This function find the server to use for the current host IP Address
# Parameters : None
# Return : echo Server to use
####
function find_server_by_ip()
{
hostname_ip=$(hostname …Run Code Online (Sandbox Code Playgroud)