LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Unable to execute .sh script (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-execute-sh-script-4175602617/)

slayer_1994 03-27-2017 04:15 AM

Unable to execute .sh script
 
Hi There

I am trying to execute a .sh script, however when I go to submit I get the following response:
Quote:

./test.sh: line 1: /opt/ca/APM/Introscope10.2.0.27/logs/IntroscopeWebView.log: Permission denied
I am able to get in that directory quite easily using cd as shown below:

Quote:

[rp1cem@wycvlapph036 logs]$ pwd
/opt/ca/APM/Introscope10.2.0.27/logs
[rp1cem@wycvlapph036 logs]$
The directory I am able to run as well:
Quote:

-rw-r--r--. 1 root root 81393779 Mar 27 10:12 IntroscopeWebView.log
Any particular reason why this isn't executing. I have provided an example of my code below:

Code:

users_connected=`/opt/ca/APM/Introscope10.2.0.27/logs/IntroscopeWebView.log | awk '{name[$11]++} END {for (i in name) print i,name[i]}' | sort -n -k 2`

echo $user_connected

Many thanks for your help in advance

Turbocapitalist 03-27-2017 04:32 AM

Yes, you cannot execute the log file. It is text data and not a program so it will fail. So you must tell awk to read the log file:

Code:

users_connected=$(awk '{name[$11]++} END {for (i in name) print i,name[i]}' /opt/ca/APM/Introscope10.2.0.27/logs/IntroscopeWebView.log | sort -k2,2n -k1,1);

slayer_1994 03-27-2017 04:44 AM

Thanks Turbocapitalist thats fixed the issue :) Also thanks for explaining to me the problem :)


All times are GMT -5. The time now is 06:17 PM.