run a shell script with echo


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users run a shell script with echo
# 1  
Old 06-20-2006
run a shell script with echo

I need to schedule a shell script that runs at the command prompt to run with crontab. When I run this at the command prompt as follows it works:
echo /usr/test/script.sh date1 date2 y | at 20:00

But if I will pass these argument (date1, date2, Y) with in a shell script (say scr1.sh) and shedule this with crontab, it doesnot run.
Suppose crontab entry is as follows:
00 20 12 * * /usr/test/scr1.sh

If I will run this at the prompt , it works ($/usr/test/scr1.sh)
Can anbody explain the reason and the way I can fix this.
Thanks in advance.
# 2  
Old 06-20-2006
Looking at the FAQs should be a good starting point.
# 3  
Old 06-20-2006
Check script ownership - compare with crontab owner.

Also check what actually happens when called from cron by adding a log location:
eg:
00 20 12 * * /usr/test/scr1.sh > /tmp/script.out 2>&1

[Can also look at the cron log for evidence of what is actually happening.]
# 4  
Old 06-20-2006
I checked the permissions and its ok. I also directed to a log file that shows the same output it show when it is running at the prompt.
I am calling a script as follows:

Script1 date1 date2 Y | at 20:00

I call the above line with in another script ( say Script2) and I schedule Script2 in cron. When I run the above line at the prompt, it works, But if I run in cron it shows in the log that its scheduled to run , but doesn't run.
Please help me.
# 5  
Old 06-20-2006
Can you tell me specific place in FAQ where I can get this information related to my question.
Thanks in advance
# 6  
Old 06-21-2006
When this problem presents itself in my world, I usually find one of the following.

The "environment" that I use and the "environment" that cron uses are different, different path setup, etc,.etc,...so make sure you have fully qualified paths to your commands, etc or at least source the correct environment to ensure your cron entry is using the same environment as you are when you are logged in.

Sometime comparing a "env >> env.out" in your cron script to your interactive login session "env" may also show you a troubling "difference",...

Hope this helps,....
# 7  
Old 06-21-2006
Quote:
Originally Posted by keerthi
Can you tell me specific place in FAQ where I can get this information related to my question.
Thanks in advance
here you go!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

How to echo output of a UNIX command (like ls -l ) using shell script.?

How do i echo the output of a unix command using shell script??? Like: echo /etc/ ls -l (2 Replies)
Discussion started by: sunny2802
2 Replies

3. Shell Programming and Scripting

Shell Script if $2 is greater than 10 then echo $1

Hi, I have a file output.txt 3258 14 32647 10 32649 10 32650 10 32651 10 32652 10 32653 10 32654 10 32655 10 32656 10 32515 09 32478 08 32555 08 35888 08 (4 Replies)
Discussion started by: amit_spl
4 Replies

4. Shell Programming and Scripting

Preserve extented ascii character when run echo comand inside bash script

Hi everyone, I'm echo some text with extended ascii characters as below: echo -e "Pr\xE9sentation du spectacle" > output or echo -e "Présentation du spectacle" > outputIf I open the file created I see this text Présentation du spectacleThe text is shown correctly in this created file when... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

5. Shell Programming and Scripting

echo prints nothing-shell script

could anyone tell me why when i execute the following script, echo returns blank set k = 1 echo $k (9 Replies)
Discussion started by: saman_glorious
9 Replies

6. Shell Programming and Scripting

shell script, echo doesn't work

#!/bin/sh something(){ echo "Inside something" echo $1 $2 } val=$(something "Hello " "world") Output expected: Inside somethingHello world But it's not echoing. (4 Replies)
Discussion started by: cola
4 Replies

7. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

8. Shell Programming and Scripting

Help need to make a shell script run for ffmpeg vhook watermaking in shell

i have a small problem getting a batxh shell script to run in shell this is the code the problem seems to be centered around the ffmpeg command, something maybe to do with the ' ' wrapping around the vhook part command this is a strange problem , if i take the ffmpeg command and... (1 Reply)
Discussion started by: wingchun22
1 Replies

9. Shell Programming and Scripting

How to Run a shell script from Perl script in Parent shell?

Hi Perl/UNIX experts, I have a problem in running a shell script from my perl script (auto.pl). I run the perl script using perl auto.pl from the shell prompt The shell script picks the files in "input" folder and procesess it. The shell script blue.sh has this code. export... (16 Replies)
Discussion started by: hifake
16 Replies
Login or Register to Ask a Question