General :: BASH Script Will Not Get Use Result Of Command When Run As Cron Job?

Jul 1, 2011

I am frustrated by running a script on the Fedora 14 computer as a cron job. I paste the code:

Code:

#!/bin/bash
#a backup script to copy data from sda to sdc
ROOTVOL=`blkid -U ea210a08-6212-4dc8-be1c-23fce3b965bc`

[code]....

So when I run this as root, for example:

Code:

# /root/myscript

the result is what I expect:

Code:

Jul 1 13:41:16 svn root: ADMIN: Executing backup-svn
Jul 1 13:41:16 svn root: using blkid ea210a08-6212-4dc8-be1c-23fce3b965bc as /dev/mapper/vg_svn_backup-lv_root

[code]....

View 3 Replies


ADVERTISEMENT

General :: How To Know If The Command Find Any Result

Oct 21, 2010

#!/bin/shLOOK_FOR="NTLMAuthenticationFilter"for i in `find ./ -name "*jar"`doecho "Looking in $i ..."grepjar -e $LOOK_FOR $idoneI wrote the script above, and try to find if there any file name LOOK_FOR exist in those jar,my quest is: grepjar -e $LOOK_FOR $ihere how can I check if there are any successful result , and output them ?

View 2 Replies View Related

General :: Use Command To Open First Search Result With Vi?

Nov 10, 2010

Every time I need to find a file and then open it, I have to use :
find ./ -name **.properties. , then copy the result, and then vi "paste the result here" .
If I need to use a mouse, it can be a little trouble. So is there any better way to do this?

View 6 Replies View Related

General :: Store Result Of Wc -l Command In Variable?

Apr 19, 2011

I want to store the result of wc -l as a variable so I can use it later in my script...so far unsuccessfully.

I have tried this:

set `echo awk '{ print $1, $6}' | wc -l` | echo $1

but it is far from working.

View 11 Replies View Related

General :: Execute Command Inside First Directory Of Each Matched Result?

Aug 8, 2011

I am working at a client who has a project where code is a mixture of different source control systems. So a layout might be like this

project/a/.svn
/a/subfolder/.svn
/b/.hg
/c/subproject/.svn
/d/.hg

So I am trying to put together a simple command that when executed from the project folder will run the appropriate hg/svn command in each project i.e:

[Code]...

Since the client has many such projects, Instead I am looking for a solution similar to find -exec where the svn/hg commands are automatically executed on each first level of match (i.e. svn up is run in the project/a folder but not in project/a/subfolder). How can such a command be constructed ?.

View 1 Replies View Related

General :: Sudo And Command Line - Get The Result Without Having To Supply A Password

Mar 31, 2011

I have the following commande /sbin/fuser -f -u /u/DT01/F010107 1>/tmp/null 2>/tmp/seausr.T0069 when executing as root 'su' this give me all user using the file. but when tried with 'sudo' i am asked with 'user password'. Is ther anyway to simply get the result without having to supply a password and to see all user not only me. (i have the file open also).

View 1 Replies View Related

General :: Result Of Type Command Is Hashed And Shows Another Path In Brackets?

May 30, 2011

I came across this reult of the type command (hashed) in another post. (see below).

Code:

fraespappp8:/data/apps > type topic_file_publish.sh
topic_file_publish.sh is hashed (/data/apps/pnbgstk/publication/topic_file_publish.sh)
This (result = hashed) is new to me.

I wonder which kernel/distro/shell it is from.

View 1 Replies View Related

General :: Bash Script Works In Terminal But Not In Cron?

Feb 17, 2011

I'm really running into a wall trying to figure this out. I have a Bash script and narrowed down the one command that doesn't seem to work via cron and it's my pgp decrypting line. Works fine if I run the command via terminal but if I run it via cron it doesn't output anything.crontab -e shows the cronjob and it runs, creates the log file with no output. Is there maybe something I need to run as well? Permissions look set, unless the cron is running as a different user(was under the assumption if it showed up under crontab while logged into that user, then it would run as that user.

View 14 Replies View Related

General :: Bash - Move Around Files Using "ls -al" Result?

May 26, 2011

How can I write a script to copy files from one directory to another directory according to last modified date?

ls -al
-rw-r--r-- 1 user user 100 2011-05-26 12:33 ABC1234_frontcover_10344000_2011-05.doc

What exactly I want to do is, Using the above bold part of ls -al result the ABC1234_frontcover_10344000_2011-05.doc file should be copied to /home/abcd/ABC1234/2011-05/26/. There should be some way to do it using value of date -r $file +%m and basename *.doc | awk -F_ '{print $1}'.

View 1 Replies View Related

General :: Bash: Calculating In Array And Storing Result In Array?

Dec 2, 2010

I have an array called arrayini which stores numbers. I want to take log to the base 2 of each of the numbers in that array and put it in file called result. I've used the following code to do it.

Code:

size=${#arrayini[@]}
for ((i=0;i<size;i++))
do
echo "scale = 12; l(${arrayini[$i]})/l(2)" | bc -l
done >result

It works fine but its taking pretty long to calculate since I've got about 230,000 items in the array. So I decided to store the result into an array hoping that it'd be faster. I tried the following code. arrayresult is where I try and store the result. The code doesn't work because of the second last line.

Code:

unset arrayresult
size=${#arrayini[@]}
for ((i=0;i<size;i++))
do
arrayresult[$i]="scale = 12; l(${arrayini[$i]})/l(2)" | bc -l
done >FILE2

There is a syntax error clearly.

View 6 Replies View Related

General :: Write A Literal Bash Command In A Bash File?

Nov 29, 2010

I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:

Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END

[code]...

View 6 Replies View Related

General :: Cron Job Command Not Found

Jun 24, 2010

I have a simple script. When I run it as cron job. I jot email saying:/bin/sh: line 1: test.tmp: command not found.Even I took first line out, I got the same error.The current shell I have is /bin/tcsh.

View 4 Replies View Related

General :: Push Command To The Background In A Cron Script?

Feb 3, 2011

I'm writing a script that performs backups from partitions on remote servers. I used to do this with ssh, but that seems to be somewhat slow, so I switched to netcat.I start a listener on the receiving server (which runs the script) like this:netcat -l -p 7000 | dd of=imagefile &and then I make the remote and start a dd piped to netcat. This works quite well started manually and the listener is waiting in the background. However, when I have cron run the same script to automate it, the netcat listener is not started, probably because the "&" thing does not work (or there is something with the piping that behaves differently then)

View 7 Replies View Related

General :: Difference Between Cron And Command Line Environment?

Feb 18, 2010

so i have a few shell scripts that execute wonderfully when i type them at the command line but they fail when they are run from cron.

for example, if i run a script from command line that contains

Code:
shopt -s nullglob

to prevent problems with for f in *.mp4 type loops, it works fine from terminal command line but when called from cron, it gives an error->

Code:
/home/centralsqwall/Videos/videochecker.sh: 91: shopt: not found

a couple other random errors as well...

so there is some difference in the shell from cron and the terminal?

i'm running ubuntu 9.10, #!/bin/bash

what are the commands i should be using to echo my environment or simulate cron environment from the terminal?

View 3 Replies View Related

General :: Bash Command History Update Before Execution Of Command

Jun 7, 2010

Bash's command history is great, especially it is useful when adding the history -a command to the COMMAND_PROMPT.However, I'm wondering if there is a way to log the commands to a file as soon as the Return key is pressed, e.g. before starting the command and not on completion of the command (using the COMMAND_PROMPT option would save the command once the prompt is there again).

I read about auditing programs like snoopy and session recorder like script but I thought they're already too complex for the simple question I have. I guess that deactivating that script logs all the output of the command would lead already in the right direction but isn't there a quicker way to solve that probelm?

View 1 Replies View Related

General :: What Does This Cryptic Bash Command Mean - Why Command Crashes

Mar 20, 2011

Possible Duplicate: What does this cryptic bash command mean? Why this command crashes Linux? :(){ :|:& };:

View 4 Replies View Related

General :: Command To Delete Bash Command History?

May 31, 2010

What's the command to delete bash command history?

View 4 Replies View Related

Programming :: Pass An Expect Command Result Into A Variable And Then Use It Again?

May 4, 2010

I'm trying to create a program that would locate the oldest file of a certain type on a server. Here's the commands:

OLDEST_PATH=`find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1`
OLDEST_FILE=`find -L $OLDEST_PATH | grep .mp3 | sort -f | head -1`
ls -al $OLDEST_FILE

I'm writing this all in expect but I'm having problems. The main problem I have is whenever I try to run the first command, I can't seem to isolate the result of the OLDEST_PATH so that the 2nd command will work. There always seems to be a newline in the variable and the result is only "find -L" command running and it bypasses the variable. If I can just figure out how to get the 1st and 2nd command to work, then I can figure out the 3rd. Here's some code:

Code:
send "find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1
"
sleep 20
expect -re "(.*)

[Code]....

I know there is a better way to write this. I've tried multiple ways and this just happens to be the last way I've tried it. If you try running this, you'll notice that there is still carriage returns after the result of OLDEST_PATH and it prevents the 2nd "find" command from working properly.

View 2 Replies View Related

Programming :: BASH Add Cron Job To Run Hourly

Mar 25, 2010

I have an rsync script I wrote that I have tested and it works perfectly when I run it manually. Now I am working on a server setup script and I have gotten my setup script to create the rsync script in /etc/cron.hourly and restart crond. To spite the fact that the script is in /etc/cron.hourly and I have restarted crond, the script does not run. With that said, how can I script adding the rsync script to run hourly as a cron job?

View 9 Replies View Related

Ubuntu :: Rsync Bash Script Different In Cron?

Feb 19, 2010

I've got a bash script that uses rsync via SSH to back up data from a remote webserver.
This script works fine when I run it myself but when it runs as a cron job I get the following error:

Code:
2010/02/20 08:15:01 [6786] Unexpected remote arg: user@www.server.com:~/www
2010/02/20 08:15:01 [6786] rsync error: syntax or usage error (code 1) at main.c(1219)

[code]....

View 9 Replies View Related

Ubuntu :: Bash Script Works Partially In Cron?

Sep 24, 2010

I have a script that pops up a jpg file several times a day as a reminder. The script is called up by crontab and it works perfectly.The issue is that I want the script to also perform a system "beep" in addition to popping up the jpg file. When I test it on the command line everything works but when I run it in cron the jpg file pops up but the beep doesn't beep. I'm thinking the problem is in the "echo -e \a" part. I must be missing something.Here is my script:

#!/bin/bash
echo -e \a
sleep01; echo -e \a

[code]....

View 8 Replies View Related

Ubuntu Servers :: Bash Script Error - Cron Job

Nov 13, 2010

Code:
#!/bin/sh
chown -Rc steven:users "/home/steven"
I have more lines in the script but each line does the same error. This is run in a cron job but it always returns.

Code:
chown: cannot access `/home/steven
': No such file or directory
But it is a valid directory I have even tried adding an / and even a space on the end and still same error.

View 7 Replies View Related

Ubuntu :: Cron Ignores Bash Script Variables

May 4, 2011

I have a personal server and a dynamic IP address, so I wrote a script to check the currently assigned IP address and compare it to the one stored in a file from the last check, and visit the update URL if it's different.

View 4 Replies View Related

Programming :: Bash Script Can't Handle Errors When Run By Cron

Jan 8, 2009

I have a script that that is supposed to send me an e-mail when a host is not responding to ping:

The script works fine when I execute it directly but when cron executes it, the ping error is never picked up by the script so the if statement is ignored.

View 4 Replies View Related

Programming :: Loading Environment Into Bash Script Called By Cron?

Mar 18, 2010

Script programming question for the experts. I have written a bash script that works fine if I execute from the shell interactively. However, once I schedule it to be executed via cron, it just wouldn't work. I believe this has to do with cron running in a different environment than the one I am in when I putty in.

The bash shell script does refer to environment variables in the .cshrc file. I guess these aren't available to the cron? How can I load them into the script if I want them to be available to the cron locally within the script?

View 1 Replies View Related

CentOS 5 :: Bash Script Under Cron Produces Broken Pipe

Apr 20, 2011

I have script which does file locking via flock and then writing it's pid into that file. It perfectly works being run by hand in terminal, running under cron on Debian, but somehow fails being run under cron on Centos 5.6. Script part and straced outputs are below.

bash code:

#setting lock
mylog "setting lockfile $LOCKFILE"
exec 200<> $LOCKFILE

[code]....

View 4 Replies View Related

General :: Email Output Of Cron Command, Sends Email But No Content?

May 28, 2010

Using CentOS. I have a cron setup to run this command: Code: /var/test.sh | mail -s "Test Cron" mr182@somewhere.com The email is sent but the output of the script is not in the email body, it's just blank. I know there is some output because there are some echo statements in the script.I don't want to get an email for all cronjobs, just this one.

View 1 Replies View Related

Ubuntu :: Get Cron To Run A Bash Script Every 15 Minutes To Change Desktop Background?

Jul 11, 2011

I'm trying to get cron to run a bash script every 15 minutes to change my desktop background

running crontab -e I added

Code:

*/15 * * * * sh /home/ME/Documents/scripts/background.sh

(at first i didnt have the sh before the path of the script but read somewhere i needed that) But it doesnt seem to be running my script works fine if ran straight from the terminal so Dont think thats the problem.

View 9 Replies View Related

General :: Bash Command Output?

Feb 12, 2011

What does the following Shell program do ??: () { :| : &} ; :Warning: My computer got hung when i tried to execute this.Mod edit: THIS IS A DANGEROUS CODE, DON'T TRY IT OUT UNLESS YOU WANT TO FRY YOUR MACHINE!

View 2 Replies View Related

General :: Bash:lex:command Not Found?

Mar 10, 2011

tell me what does error message signify and what should be done to rectify it...bash : lex :command not found

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved