所以我無法加載外部軟件,因爲這是一個腳本,用於在設置新的mac工作站時進行測試,並且腳本記錄每個測試的通過/失敗/空(跳過)狀態。除鼠標移動外,我已完成所有工作。因爲這是爲了工作,安裝技術人員必須運行這個腳本,並且他們沒有超級用戶權限,並且需要在USB驅動器上執行。這可能嗎?我將如何使用BASH(mac)來查找鼠標指針位置?
編輯的詳細信息:
我有一個正在測試的科技股,因爲他們走動,他們的機器掛接到碼頭多個工作站。它測試內部和外部網絡,以及鍵盤鼠標和聲音。我有鍵盤和網絡的東西。我仍在學習如何使用文本到語音引擎播放聲音,並詢問用戶是否播放。到目前爲止所有的數據都被寫成一個變量,然後保存到一個csv。由於我正在與管理層就他們希望顯示數據的方式進行合作,因此我仍在撰寫csv部分。
TLDR科技移動鼠標,我需要檢查,如果小鼠在腳本中移動和寫合格/不合格
下面是我(略作修改,保留隱私)
#!/bin/bash
#this pulls the logged in user's name.
runninguser=$(whoami)
#end of line
#script version
scrver="script version 0.0.1"
#end script version
#welcome text
echo Welcome to the Mac Install Test Script, by [ME]. This is $scrver
#end welcome text
# this section is what makes the directory where the files will
# be temporarily saved to.
mkdir -p ~/tmp
#this section asks for tech's last name and first name
echo Hi $runninguser, I am the Mac Automated Test Script. Nice to meet you!
# This section is for getting the customer name
echo "What is your customer's last name for this workstation?"
read custLname
echo "Thank you, now what is your customer's first name?"
read custFname
# This section is for testing to see if the internet connection works.
echo "Now we are going to test the external network connection."
curl -o ~/tmp/elgoogs http://www.google.com
testout1=~/tmp/elgoogs
if grep -q "/body" "$testout1"
then echo "pass" && internettest="PASS"
else echo "fail" && internettest="FAIL"
fi
#this section is for testing the internal network connection
curl -o ~/tmp/[REDACTED] http://[REDACTED].gov
testin1=~tmp/[REDACTED]
if grep -q "/body" "$testin1"
then echo "pass" && intranettest="PASS"
else echo "fail" && intranettest="FAIL"
fi
#The next section is for keyboard testing
echo "We are now going to test the keyboard"
sleep 2
echo "Please press the enter key!"
while true; do
read -rsn1 kinput
if [ "$kinput" = 「」 ]; then
echo "keyboard test passed!" && kbtest="PASS" && break
fi
done
# VARIABLES & STRINGS
#
# testout1 is filepath for internet test
# internettest is the pass/fail state for outside network testing.
# runninguser is the currently running user
# scver is the version of the script being run
# custLname is the Customer's Last Name
# custFname is the Customer's First Name
# testin1 is the intranet test
# intranettest is the pass/fail state for inside network testing.
# kinput is the input variable, what is being waited for.
# kbtest is the pass/fail state for keyboard test
#
沒有什麼內置於bash本身,對工作很有用,甚至*可用於* bas從某種意義上講,它可能不能用於任何能夠啓動子進程並讀取其輸出的其他語言。 –
好的,這是有道理的。你會如何提出前進的方向? – wertyy102
一個很好的開始將提供足夠的細節,讓人們可以找出你真正想要的東西。你有一個用戶操作鼠標,你試圖找出它是否工作?應該模擬設備的腳本,並且您正試圖弄清楚* *可以工作嗎?具體說明你想要完成什麼,以及*少*具體說明你想用什麼工具來達到目標(所以有人可以爲工作提供最佳工具建議,而不是最適合你對什麼的偏見解決方案看起來像)。 –