从shellcript生成的文件无法打开,权限只显示“???????”

时间:2011-03-17 13:47:05

标签: bash permissions

奇怪的是。我有一个需要与sudo一起运行的shellcript,因为它使用dumpcap

#!/bin/bash
# Simulates the transmissions with Sirannon

mkdir -p 3dvideos_streamed
mkdir -p 3dvideos_packetcapture

for file in Alt_moabit Book_arrival Door_flowers Leaving_laptop
do
  for qp in 10 15 25 32 45 60
  do
    echo "Now simulating transmission of $file with QP $qp ... "

    echo "Starting dumpcap ... "
    touch 3dvideos_packetcapture/$file-$qp.cap
    dumpcap -i lo -f "udp port 5000" -a duration:15 -w 3dvideos_packetcapture/$file-$qp.cap &

    cp 3dvideos_encoded/$file/qp$qp/test.264 3dvideos_streamed/$file-$qp-in.264 &

    echo "Starting sirannon ... "
    sirannon sirannon-0.6.8/dat/xml/mvc.xml 3dvideos_encoded/$file/qp$qp/test.264 3dvideos_streamed/$file-$qp 3dvideos_streamed/$file-$qp-out.264
    echo "Sirannon is done streaming."

    sleep 15    

  done
done

echo "Fixing permissions ... "
chmod -R 655 3dvideos_streamed
chmod -R 655 3dvideos_packetcapture

现在我离开了:

werner@savant:~/CACMTV$ ls -la 3dvideos_packetcapture/
ls: cannot access 3dvideos_packetcapture/Alt_moabit-60.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Book_arrival-60.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/..: Permission denied
ls: cannot access 3dvideos_packetcapture/Leaving_laptop-10.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Leaving_laptop-32.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Leaving_laptop-60.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Alt_moabit-25.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/.: Permission denied
ls: cannot access 3dvideos_packetcapture/Door_flowers-10.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Door_flowers-15.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Book_arrival-15.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Leaving_laptop-15.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Door_flowers-25.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Alt_moabit-10.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Door_flowers-32.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Leaving_laptop-25.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Book_arrival-45.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Alt_moabit-45.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Door_flowers-45.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Book_arrival-10.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Alt_moabit-15.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Door_flowers-60.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Leaving_laptop-45.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Alt_moabit-32.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Book_arrival-25.cap: Permission denied
ls: cannot access 3dvideos_packetcapture/Book_arrival-32.cap: Permission denied
total 0
d????????? ? ? ? ?                ? .
d????????? ? ? ? ?                ? ..
-????????? ? ? ? ?                ? Alt_moabit-10.cap
-????????? ? ? ? ?                ? Alt_moabit-15.cap
-????????? ? ? ? ?                ? Alt_moabit-25.cap
-????????? ? ? ? ?                ? Alt_moabit-32.cap
-????????? ? ? ? ?                ? Alt_moabit-45.cap
-????????? ? ? ? ?                ? Alt_moabit-60.cap
-????????? ? ? ? ?                ? Book_arrival-10.cap
-????????? ? ? ? ?                ? Book_arrival-15.cap
-????????? ? ? ? ?                ? Book_arrival-25.cap
-????????? ? ? ? ?                ? Book_arrival-32.cap
-????????? ? ? ? ?                ? Book_arrival-45.cap
-????????? ? ? ? ?                ? Book_arrival-60.cap
-????????? ? ? ? ?                ? Door_flowers-10.cap
-????????? ? ? ? ?                ? Door_flowers-15.cap
-????????? ? ? ? ?                ? Door_flowers-25.cap
-????????? ? ? ? ?                ? Door_flowers-32.cap
-????????? ? ? ? ?                ? Door_flowers-45.cap
-????????? ? ? ? ?                ? Door_flowers-60.cap
-????????? ? ? ? ?                ? Leaving_laptop-10.cap
-????????? ? ? ? ?                ? Leaving_laptop-15.cap
-????????? ? ? ? ?                ? Leaving_laptop-25.cap
-????????? ? ? ? ?                ? Leaving_laptop-32.cap
-????????? ? ? ? ?                ? Leaving_laptop-45.cap
-????????? ? ? ? ?                ? Leaving_laptop-60.cap

我可以看到Nautilus中的文件,但我无法打开它们:

如何解决此问题 - 如何让dumpcap获得必要的权限,同时保留我的权限,我需要如何更改我的shellcript?

2 个答案:

答案 0 :(得分:2)

我想目录3dvideos_packetcapture已经存在并且由用户werner拥有。 mkdir -p 3dvideos_packetcapture未创建新目录,也未更改所有权。但是使用chmod -R 655 3dvideos_packetcapture,您删除了用户werner的执行权限。 我想你必须改为

chmod -R 755 3dvideos_packetcapture

或 - 如果您不想触及上述行,请将所有权更改为root

chown root 3dvideos_packetcapture

。但也许最好的可能是

chown -R werner.werner 3dvideos_packetcapture 3dvideos_streamed
chmod -R 755 3dvideos_packetcapture 3dvideos_streamed

在剧本的最后。

答案 1 :(得分:1)

事实证明,最简单的解决方案就是将命令运行为:

sudo ./script.sh -u werner

然后不需要chmod/chown的所有行。