LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-27-2017, 04:15 AM   #1
slayer_1994
Member
 
Registered: Feb 2017
Posts: 38

Rep: Reputation: Disabled
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
 
Old 03-27-2017, 04:32 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,314
Blog Entries: 3

Rep: Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723
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);

Last edited by Turbocapitalist; 03-27-2017 at 04:40 AM. Reason: sort
 
1 members found this post helpful.
Old 03-27-2017, 04:44 AM   #3
slayer_1994
Member
 
Registered: Feb 2017
Posts: 38

Original Poster
Rep: Reputation: Disabled
Thanks Turbocapitalist thats fixed the issue Also thanks for explaining to me the problem
 
  


Reply

Tags
newbie, permission denied, scripting, shell script, unix



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to execute file (I have execute permission) leoecco Linux - General 1 07-20-2013 10:20 PM
Unable to execute "reboot" in cgi script jcaga Fedora 4 05-10-2012 08:45 AM
unable to execute shell scritp from php script kamlesh_kmr Programming 2 10-17-2011 12:43 AM
[SOLVED] [Ubuntu] apt libxml-sax-perl "unable to execute installed post-installation script" XXLRay Linux - Software 1 07-17-2010 09:20 AM
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 02:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration