R
R
r3star2018-03-06 19:19:19
linux
r3star, 2018-03-06 19:19:19

A non-root user cannot execute the script, what is wrong in the script?

good afternoon, I just started to study unix, tell me what's wrong.
when the script is executed by a non-root user, it writes a permissions denied error, help me figure out where I screwed up =)

#!/bin/bash

for i in $(free > /home/restar/logs/memory.txt | cat /proc/stat > /home/restar/logs/cpu.txt) {1..10}  
do
sleep 1
done

for ii in $(cat /var/log/messages > /home/restar/logs/messages.txt | journalctl -p err > /home/restar/logs/erors.txt) {1..10} # 
do
sleep 1
done

for iii in $(ip a > /home/restar/logs/seti.txt) # без цикла будет проще?
do
sleep 
done

[[email protected] scripts]$ ./restar2.sh
./restar2.sh: line 6: /restar/logs/memory.txt: Permission denied
./restar2.sh: line 6: /restar/logs/cpu.txt: Permission denied
./restar2.sh: line 12: /restar/logs/messages.txt: Permission denied
./restar2.sh: line 12: /restar/logs/erors.txt: Permission denied
./restar2.sh: line 14 : /restar/logs/seti.txt: Permission denied
it, as I understand it, still does not give me access to the log folder where I want to write the files, although I gave the rights via chmod +xwr /restar from under the root did =) where I messed up ?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
S
Stanislav Pugachev, 2018-03-06
@r3star

Wang that /var/log/messages is not available to you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question