Not able to run shell Script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Not able to run shell Script

Shell Programming and Scripting


Tags
shell script

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-10-2013
nitinupadhyaya8 nitinupadhyaya8 is offline
Registered User
 
Join Date: Oct 2013
Last Activity: 11 July 2014, 5:30 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Not able to run shell Script

Hi,

1) When I run a script name myscript.sh, I do not see any error nor does the script get executed. What can be the possible reason? This was an interview question asked recently

eg.

sh myscript.sh

2) I manually check if my directory is being updated every 5 mins. How can I automate this shell scripting?

Last edited by nitinupadhyaya8; 11-11-2013 at 12:46 AM.. Reason: Got a reply to change the subject
Sponsored Links
    #2  
Old 11-10-2013
Bashar Bashar is offline
Registered User
 
Join Date: Aug 2001
Last Activity: 11 November 2013, 7:16 AM EST
Location: Kuwait
Posts: 74
Thanks: 0
Thanked 1 Time in 1 Post
1) try sh -x or bash -x
2) automating use crontab
Sponsored Links
    #3  
Old 11-11-2013
nitinupadhyaya8 nitinupadhyaya8 is offline
Registered User
 
Join Date: Oct 2013
Last Activity: 11 July 2014, 5:30 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Bashar,

I believe 1) try sh -x or bash -x
would only help if the script ran.

But in my case, the script did not run and I did not get any error either.
This was the scenario given to me during an interview.
    #4  
Old 11-11-2013
linuxrulez linuxrulez is offline
Registered User
 
Join Date: Nov 2013
Last Activity: 26 November 2013, 2:00 PM EST
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Question:
------------
When I run a script name myscript.sh, I do not see any error nor does the script get executed. What can be the possible reason?

Answer:
------------
First whether the script have executable permission(+x) permission. If the script did not have executable permission it will not run as a local user

If you are running the script as root user executable permission is not required.

If you run a script and no errors available means, First open the shell script and see what content is available inside it.

2. Question
-----------------

I manually check if my directory is being updated every 5 mins. How can I automate this shell scripting?

Answer:
-----------

One word "crontab".

Go to google and search for crontab with examples in linux lot of articles are available.
Sponsored Links
    #5  
Old 11-11-2013
Bashar Bashar is offline
Registered User
 
Join Date: Aug 2001
Last Activity: 11 November 2013, 7:16 AM EST
Location: Kuwait
Posts: 74
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by nitinupadhyaya8 View Post
Hi Bashar,

I believe 1) try sh -x or bash -x
would only help if the script ran.

But in my case, the script did not run and I did not get any error either.
This was the scenario given to me during an interview.
if just returned to command prompt then maybe the script does nothing?
Sponsored Links
    #6  
Old 11-11-2013
nitinupadhyaya8 nitinupadhyaya8 is offline
Registered User
 
Join Date: Oct 2013
Last Activity: 11 July 2014, 5:30 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for your reply guys.
I guess the file would have nothing in it.
Sponsored Links
    #7  
Old 11-11-2013
wisecracker's Avatar
wisecracker wisecracker is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 22 August 2014, 8:47 AM EDT
Location: Loughborough
Posts: 605
Thanks: 128
Thanked 128 Times in 105 Posts
This script has something in it but I have named it useless.sh...

Code:
#/bin/bash --posix
NOP()
{
	:
}
NOP
exit 1

Results...

Code:
Last login: Mon Nov 11 20:00:59 on ttys000
AMIGA:barrywalker~> chmod 755 useless.sh
AMIGA:barrywalker~> ./useless.sh
AMIGA:barrywalker~> echo "$?"
1
AMIGA:barrywalker~> _

As you can see it works perfectly the way you described and my exit _code_ was correct.
There were no error reports, nothing appeared on screen and and my prompt returned as normal.

Maybe your script IS running but without seeing any of your attempts we can never know...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Run a shell script from one host which connext to remote host and run the commands SN2009 Shell Programming and Scripting 6 04-13-2009 04:39 AM
How to run cmds after changing to a new env (shell) in a shell script charlei Shell Programming and Scripting 6 10-14-2008 03:18 PM
Help need to make a shell script run for ffmpeg vhook watermaking in shell wingchun22 Shell Programming and Scripting 1 09-27-2008 06:52 AM
How to Run a shell script from Perl script in Parent shell? hifake Shell Programming and Scripting 16 08-28-2007 08:42 PM



All times are GMT -4. The time now is 01:18 PM.