Sponsored Content
Full Discussion: Strange error in bash script
Top Forums Shell Programming and Scripting Strange error in bash script Post 302389527 by saariko on Monday 25th of January 2010 08:09:23 AM
Old 01-25-2010
Thanks for your ideas

set -x did gave me the output, but no apparent error what so ever
Code:
+ . ../SCRIPTS/test.sh
++ set -x
++ APP_NAME=app_com_site
++ wikiname=app_com_site
++ BACKUP_DIR=/home/app/backup/DAILY
++ DB_NAME=app_com_db
++ DB_USER=app_com_admi
++ DB_PASS=ermno
++ FILES_TO_KEEP=2
+++ date +%Y-%m-%d
++ timestamp=2010-01-25
++ dbdump=/home/app/backup/DAILY/app_com_site-2010-01-25.sql.gz
++ filedump=/home/app/backup/DAILY/app_com_site-2010-01-25.files.tgz
++ echo 'creating database dump:' /home/app/backup/DAILY/app_com_site-2010-01-25.sql.gz
creating database dump: /home/optitex/backup/DAILY/app_com_site-2010-01-25.sql.gz
++ gzip
++ mysqldump --database app_com_db -u appx_com_admi -permpass --add-drop-table -B
++ pushd /home/app/public_html
~/public_html ~/backup/DAILY
++ popd
~/backup/DAILY
++ echo 'Done!'
Done!

Adding the brackets to my source code, didn't change the result.

I started to think that it's permission issue.
The target folder is 755, and owned by the same user that is running the script (other user that runs the cron job is root - at night run). so I don't think it's permissions.

Why is it that if I put a direct file name it works, but using a parameter it doesn't?

---------- Post updated at 03:09 PM ---------- Previous update was at 02:42 PM ----------

I had another try, to see if I can make this work in a different way:

These two lines are working, the name of the output sql file and gz file are hardcoded.
Code:
mysqldump --database $DB_NAME -u $DB_USER -p$DB_PASS --add-drop-table -B > "$BACKUP_DIR"/dump.sql

gzip "$BACKUP_DIR"/dump.sql


These 2 lines are NOT working
Code:
mysqldump --database $DB_NAME -u $DB_USER -p$DB_PASS --add-drop-table -B > "$BACKUP_DIR"/"$APP_NAME-$timestamp.sql.gz"

gzip "$BACKUP_DIR"/"$APP_NAME-$timestamp.sql.gz"

My guess is that something is weird with the timestamp naming? how can that be?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

error in bash script 'if' loop

SEND_MESSAGE=test echo $SEND_MESSAGE if then echo `date` > update_dt_ccaps.lst echo "The file transfer failed" >> update_dt_ccaps.lst SEND_MESSAGE=false fi The above code is showing error in bash shell as : ./test: line 5: [: test: integer expression expected ... (2 Replies)
Discussion started by: DILEEP410
2 Replies

2. Shell Programming and Scripting

Bash Script error?

I'm currently playing with the below script; #!/bin/sh for d in /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \ /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \ /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \ ... (13 Replies)
Discussion started by: JayC89
13 Replies

3. Shell Programming and Scripting

Help in error seen in the Bash script

Hi, I am currently encounter an error of:- ./max.bash: line 45: then max=0 else max=$maximum It seems that it does not allow max to assigned with floating numbers. Please help. Thanks. (2 Replies)
Discussion started by: ahjiefreak
2 Replies

4. Shell Programming and Scripting

Getting error on for loop - bash script

Hi, I am working on bash script after a long time. I am getting error near done statement while running a for loop snippet. The error says "Syntax error near unexpcted token 'done'" please suggest what could be wrong. here is the snippet elements=${#option_arr} //an array of values... (1 Reply)
Discussion started by: arundhati_s
1 Replies

5. Shell Programming and Scripting

BASH script outputting strange file formats

Hi I am very new to using BASH, but I have a problem with a piece of script that I have been working on. Basically the script goes through a mailbox file looking at particular aspects of the file, for example how many spamwords there are email address etc. It does this pretty well except for an... (13 Replies)
Discussion started by: 9aza
13 Replies

6. Shell Programming and Scripting

Strange suppression of output with bash and cygwin

Hi, although I am not expert in bash, so please forgive me if this is silly, I think that this is strange: I have this command: find . -type f -print0 |xargs -0 grep -i -e 'some rexp' and it works fine. But when I create a bash script (on cygwin) to run this command, there is no output !!!... (3 Replies)
Discussion started by: Niki999
3 Replies

7. Shell Programming and Scripting

Strange fork error while running script

more run.sh !/bin/bash input="data.txt" while IFS= read -r var do startdir="/web/logs" searchterm=$(echo $var | awk -F'=' '{print $1}') replaceterm=$(echo $var | awk -F'=' '{print $2}') find "$startdir" -type f -exec grep -l "$searchterm" {} + | while read file do if sed -e... (1 Reply)
Discussion started by: mohtashims
1 Replies

8. Shell Programming and Scripting

Bash - concatenate string - strange variable scoping

Hello, I am trying to concatenate a string in a bash script like this: runCmd="docker run -e \"IMAGE_NAME=$IMAGE_NAME\" " env | grep "$ENV_SUFFIX" | while read line; do envCmd="-e \"${line}\" " runCmd=$runCmd$envCmd echo $runCmd # here concatenation works fine done echo... (3 Replies)
Discussion started by: czabak
3 Replies

9. Shell Programming and Scripting

Ubuntu 16 Bash strange output

Hello, I work in Ubuntu 16.04, I am new to Bash and something is wrong with my script, please help. I have a few hundreds of subjects data (like subj003.nii.gz, subj012.nii.gz etc. up to subj567.nii.gz) in a directory /usr/afewmoredirectories/subjects. I may run for each subject a command... (5 Replies)
Discussion started by: lim-lim
5 Replies

10. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
SYSPROFILE(8)						      System Manager's Manual						     SYSPROFILE(8)

NAME
sysprofile - modular centralized shell configuration DESCRIPTION
sysprofile is a generic approach to configure shell settings in a modular and centralized way mostly aimed at avoiding work for lazy sysad- mins. It has only been tested to work with the bash shell. It basically consists of the small /etc/sysprofile shell script which invokes other small shell scripts having a .bash suffix which are contained in the /etc/sysprofile.d/ directory. The system administrator can drop in any script he wants without any naming convention other than that the scripts need to have a .bash suffix to enable automagic sourcing by /etc/sysprofile. This mechanism is set up by inserting a small shell routine into /etc/profile for login shells and optionally into /etc/bashrc and/or /etc/bash.bashrc for non-login shells from where the actual /etc/sysprofile script is invoked: if [ -f /etc/sysprofile ]; then . /etc/sysprofile fi For using "sysprofile" under X11, one can source it in a similar way from /etc/X11/Xsession or your X display manager's Xsession file to provide the same shell environment as under the console in X11. See the example files in /usr/share/doc/sysprofile/ for illustration. For usage of terminal emulators with a non-login bash shell under X11, take care to enable sysprofile via /etc/bash.bashrc. If not set this way, your terminal emulators won't come up with the environment defined by the scripts in /etc/sysprofile.d/. Users not wanting /etc/sysprofile to be sourced for their environment can easily disable it's automatic mechanism. It can be disabled by simply creating an empty file called $HOME/.nosysprofile in the user's home directory using e.g. the touch(1) command. Any single configuration file in /etc/sysprofile.d/ can be overridden by any user by creating a private $HOME/.sysprofile.d/ directory which may contain a user's own version of any configuration file to be sourced instead of the system default. It's names have just to match exactly the system's default /etc/sysprofile.d/ configuration files. Empty versions of these files contained in the $HOME/.syspro- file.d/ directory automatically disable sourcing of the system wide version. Naturally, users can add and include their own private script inventions to be automagically executed by /etc/sysprofile at login time. OPTIONS
There are no options other than those dictated by shell conventions. Anything is defined within the configuration scripts themselves. SEE ALSO
The README files and configuration examples contained in /etc/sysprofile.d/ and the manual pages bash(1), xdm(1x), xdm.options(5), and wdm(1x). Recommended further reading is everything related with shell programming. If you need a similar mechanism for executing code at logout time check out the related package syslogout(8) which is a very close compan- ion to sysprofile. BUGS
sysprofile in its current form is mainly restricted to bash(1) syntax. In fact it is actually a rather embarrassing quick and dirty hack than anything else - but it works. It serves the practical need to enable a centralized bash configuration until something better becomes available. Your constructive criticism in making this into something better" is very welcome. Before i forget to mention it: we take patches... ;-) AUTHOR
sysprofile was developed by Paul Seelig <pseelig@debian.org> specifically for the Debian GNU/Linux system. Feel free to port it to and use it anywhere else under the conditions of either the GNU public license or the BSD license or both. Better yet, please help to make it into something more worthwhile than it currently is. SYSPROFILE(8)
All times are GMT -4. The time now is 10:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy