I am trying to get a cronjob to pipe output into a dated file in a specified (folder) location.
My crontab entry looks something like this:
* * * * * /some/path/test.sh >> $(date "+/home/oompah/logs/%Y%m%d.test.log")
What I don’t understand is that when I type this command at the console, I get the correct string:
echo $(date "+/home/oompah/logs/%Y%m%d.test.log")
/home/oompah/logs/20110329.test.log
What’s causing this error and how may I fix it?
bash version info is:
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
asked Mar 29, 2011 at 14:09
oompahloompahoompahloompah
8,93718 gold badges61 silver badges90 bronze badges
5
You should excape the percent signs in your crontab:
* * * * * /some/path/test.sh >> $(date "+/home/oompah/logs/%Y%m%d.test.log")
Percent (%
) signs have a special meaning in crontabs. They are interpreted as newline characters.
answered Mar 29, 2011 at 14:36
5
Put the date command inside the script. cron
isn’t necessarily running the shell you think it is.
answered Mar 29, 2011 at 14:11
bmarguliesbmargulies
96.5k39 gold badges182 silver badges308 bronze badges
2
make sure you have shebang #!/bin/bash
as the first line in your script. Also, as bmargulies
stated, put the date
command inside the script if possible.
answered Mar 29, 2011 at 14:14
kurumikurumi
24.9k4 gold badges44 silver badges51 bronze badges
I am trying to use a backup script that will backup my sql database and website files.
I am running Ubuntu 12.04 32 bit version and zPanel.
Also what are these variables:
MYSQL=»$()»
MYSQLDUMP=»$()»
GZIP=»$()»
I assume the first one is DB name.
Here is the script:
#!/bin/sh
#----------------------------------------------------------------
# Daily Backup Routine - Backup and Sync to Dropbox
# This script creates a backup using today's date, then deleted
# any backups made 3 days ago. If run every day it will ensure
# you have a week's worth of backups of your MySQL databases and
# zPanel web directories.
#
# Uses whatever Dropbox account is running on the server.
#
# Written by Richard Ferreira for the backup of zPanel websites.
# Contact me - richard[at]beetle001.com
#----------------------------------------------------------------
#
# Before we get started, we should set some parameters. We'll need these for later.
# The webserver's datafiles:
WEBDIR="/var/zpanel/hostdata/"
# Where do we want the backup to go? (SET THIS - IT'S A TEMP FOLDER)
BACKUP="/root/backup-temp"
# Where is our dropbox folder? (SET THIS TO YOUR ABSOLUTE BACKUP PATH)
DROPBOX="/root/Dropbox/Backups
# What do we want our date to look like?
NOW=$(date +"%d-%m-%Y")
# We need to know the date 3 days ago to purge any backups that were made 3 days ago.
# This ensures we don't keep unnecessarily old backups.
# It doesn't matter if it skips one every now and then - we'll just have to check manually from time to time.
# If you want to keep more days backups, change the "3 days ago" to "x days ago"
DAYSAGO=$(date --date="3 days ago" +"%d-%m-%Y")
# What should our file backup look like?
WEBFILE="webdirs-full-$NOW.tar.gz"
# Our MySQL Login information and some paths (we'll use 'which' to make sure we get them):
SQLUSER="root"
# Don't forget to change the root password here!
SQLPASS="xxxxxxxxxxxx"
SQLHOST="localhost"
MYSQL="$(db-name)"
MYSQLDUMP="$(db-name)"
GZIP="$(.gz)"
#
# Let's just, for sanity's sake, make sure our temp backup folder exists.
mkdir $BACKUP
# DON'T EDIT ANYTHING BELOW THIS LINE
#----------------------------------------------------------------
# Now let's start!
# Let's get the databases that we want to backup.
DBS="$($MYSQL -u $SQLUSER -h $SQLHOST -p$SQLPASS -Bse 'show databases')"
# Now let's dump them to .sql files and put them in our backup directory.
for db in $DBS
do
FILE=$BACKUP/mysql-$db.$NOW.gz
$MYSQLDUMP -u $SQLUSER -h $SQLHOST -p$SQLPASS $db | $GZIP -9 > $FILE
done
#
# Let's shove the whole webserver directory into a tarball and throw that in with the sql files:
tar -zcvf /root/backup/$WEBFILE $WEBDIR
# That's all done - we should put the backups on Copy by putting them into our Copy folder.
# First let's make a folder for today.
mkdir $DROPBOX/$NOW
# Copy our backups into it.
cp -R $BACKUP/* $DROPBOX/Asterix/$NOW
# We can delete the backup we made 3 days ago from Copy now.
rm -rf $DROPBOX/$DAYSAGO
# And clear out the temporary director for next time.
rm $BACKUP/*
# Job well done!
# Have a beer and relax!
Here is my problem:
When I try to run the script I get this error:
./backup.sh: 66: ./backup.sh: Syntax error: Unterminated quoted string
If anyone could help me with this would appreciate it a lot!
I’ve added some code to the end of a bash script I am using. The code shown here is intended to copy a csv into my postgres table, and then remove brackets, quotes and double quotes from the title column of test_table.
#copy csv to table
psql -U postgres -d ebay_sold -c "COPY test_table (item_number,title,url,price) FROM '/home/perl_experiments/xmlcsv.txt' (DELIMITER('|'))"
#Remove brackets, then double qotes, then single quotes from title column
psql -U postgres -d ebay_sold -c "UPDATE test_table SET title = regexp_replace(title, '[()]', '', 'g')"
psql -U postgres -d ebay_sold -c "UPDATE test_table SET title = regexp_replace(title, '"', '', 'g')"
psql -U postgres -d ebay_sold -c "UPDATE test_table SET title = regexp_replace(title, '''', '', 'g')"
The copying to the postgres table works fine. The remove brackets, double quotes and single quotes work as expected when applied manually in postgres. However, when I run the bash script, I get:
line 27: syntax error: unterminated quoted string
The error which i’m getting relates to the line
psql -U postgres -d ebay_sold -c "UPDATE test_table SET title = regexp_replace(title, '"', '', 'g')"
As I say this command works fine when performed manually when i’m logged into postgres, does anyone have any idea why i’m getting this error when I run the script in bash?
I am trying to run a .run
file, I log in as SU and run the following command:
sh xampp-linux-x64-1.8.3-1-installer.run
but I am getting the following error:
Syntax error: Unterminated quoted string
What is the cause of this?
Hennes
64.3k7 gold badges110 silver badges165 bronze badges
asked Nov 20, 2013 at 14:55
2
The cause is probably an unterminated quoted string in the installer. (well duh!).
Either run it with the -x option to get more debug information, or open the installer in an editor and look for unmatched pairs of quotes.
Example:
#!/usr/bin/env bash
#My demo installer!
#
echo "starting here!"
echo "and an error in this line
echo "We will never get here!"
Notice the missing closing quote ("
) in the second echo line.
Edit:
I just downloaded a file called xampp-linux-x64-1.8.3-1-installer.run
from sourceforge (which I assume is the same file as you are using) and when I opened it in vim I noticed it starts with ^?ELF^
. This file seems to be an ELF binary.
Using the file command on it confirms this:
file: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, stripped
It is not a shell script and the normal way to execute it would either be:
xampp-linux-x64-1.8.3-1-installer.run
(assuming the directory is in your search path),- or with the full path prepended. E.g.
./xampp-linux-x64-1.8.3-1-installer.run
if you are already in the same directory where the file is. (This is why @erhun’s answer worked).
answered Nov 20, 2013 at 15:00
HennesHennes
64.3k7 gold badges110 silver badges165 bronze badges
2
It will work with this way.
chmod +x xampp-linux-x64-1.8.3-1-installer.run
./xampp-linux-x64-1.8.3-1-installer.run
answered Nov 20, 2013 at 15:09
erhunerhun
1414 bronze badges
0
I tried to install xampp-linux-x64-1.8.3-2-installer.run and had the same message.
None of these answers worked for me because I think this is the x64 bit version and I was trying to install it on a 32bit Linux Mint.
Instead I downloaded xampp-linux-1.8.3-2-installer.run (notice the lack of x64 in the file name) and this one worked.
I did the chmod , then sudo ./xampp-linux-1.8.3-2-installer.run and after good few seconds i had the gui installer running.
PS. You’ll need to go to sourceforge because apachefriends.org website will give you x64 version as default download.
answered Feb 14, 2014 at 20:21
Looks not a problem with 64-bit OS.
I got same error and ‘uname -m’ can confirm it (displays x86_64), although I was already sure specifically purchase 64-bit machine.
Looks like while downloading (wget for many hours, very slow mobile Internet), ‘xampp-linux-x64-1.8.3-4-installer.run’ got corrupted!
answered Apr 30, 2014 at 18:49
10 More Discussions You Might Find Interesting
2. Shell Programming and Scripting
awk string comparison unterminated quoted string andrule of thumb
I have the logic below to look up for matches within the columns between the two files with awk.
In the if statement is where the string comparison is attempted with ==
The issue seems to be with the operands, as
1. when » ‘${SECTOR}’ » — double quote followed by single quote — awk matches… (1 Reply)
Discussion started by: deadyetagain
3. Shell Programming and Scripting
sed returns error «sed: -e expression #1, char 18: unterminated `s’ command»
Hello All,
I have something like below
LDC100/rel/prod/libinactrl.a
LAA2000/rel/prod/libinactrl.a
I want to remove till first forward slash that is outputshould be as below
rel/prod/libinactrl.a
rel/prod/libinactrl.a
How can I do that ??? (8 Replies)
Discussion started by: anand.shah
4. Shell Programming and Scripting
grep with «[» and «]» and «dot» within the search string
Hello.
Following recommendations for one of my threads, this is working perfectly :
#!/bin/bash
CNT=$( grep -c -e «some text 1» -e «some text 2» -e «some text 3» «/tmp/log_file.txt» )
Now I need a grep success for some thing like :
#!/bin/bash
CNT=$( grep -c -e «some text_1… (4 Replies)
Discussion started by: jcdole
5. Shell Programming and Scripting
awk? extract quoted «» strings from multiple lines.
I am trying to extract multiple strings from snmp-mib files like below.
——
$ cat IF-MIB.mib
<snip>
linkDown NOTIFICATION-TYPE
OBJECTS { ifIndex, ifAdminStatus, ifOperStatus }
STATUS current
DESCRIPTION
«A linkDown trap signifies that the SNMP entity, acting in… (5 Replies)
Discussion started by: genzo
6. Shell Programming and Scripting
how to use «cut» or «awk» or «sed» to remove a string
logs:
«/home/abc/public_html/index.php»
«/home/abc/public_html/index.php»
«/home/xyz/public_html/index.php»
«/home/xyz/public_html/index.php»
«/home/xyz/public_html/index.php»
how to use «cut» or «awk» or «sed» to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Discussion started by: timmywong
7. Shell Programming and Scripting
Using sed to find text between a «string » and character «,»
Hello everyone
Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) «string » and before a «,». I have tried
sed -n ‘s/.*string (*),.*/1/p’ filewith some, but limited success. This gives out all… (10 Replies)
Discussion started by: haggismn
8. Shell Programming and Scripting
Unterminated quoted string
Hello!
I wroted a little script that should check for new updates on a server and get them if any. The problem is, every time I run it with sh, I’m getting an «script: 20: Syntax error: Unterminated quoted string» error!
The problem is, there isn’t any «unterminated quoted string» in my script:… (2 Replies)
Discussion started by: al0x
10. Shell Programming and Scripting
Syntax error: Unterminated quoted string
I keep having problems when exicuting this file. It always gives me the error message «36: Syntax error: Unterminated quoted string»
If someone could help me edit this it would be much appreciated.
#!/bin/sh
#
# This will continue adding numbers
# untill the total is greater than 1,000
#… (5 Replies)
Discussion started by: evilSerph
кавычки в переменной (bash, dash)
Модераторы: /dev/random, Модераторы разделов
-
Bizdelnick
- Модератор
- Сообщения: 19825
- Статус: nulla salus bello
- ОС: Debian GNU/Linux
кавычки в переменной
$
$ args="'head -n1' 'tail -n1'"
$ echo $args
'head -n1' 'tail -n1'
$ echo | pee $args
sh: 0: Illegal option -1
sh: 1: Syntax error: Unterminated quoted string
sh: 0: Illegal option -1
sh: 1: Syntax error: Unterminated quoted string
$
ЧЯДНТ?
Интересует не решение конкретной проблемы (она уже решена совершенно другим путём), а именно причина ошибки.
Пишите правильно:
в консоли вку́пе (с чем-либо) в общем вообще |
в течение (часа) новичок нюанс по умолчанию |
приемлемо проблема пробовать трафик |
-
Bizdelnick
- Модератор
- Сообщения: 19825
- Статус: nulla salus bello
- ОС: Debian GNU/Linux
Re: кавычки в переменной
Сообщение
Bizdelnick » 28.09.2013 20:01
А, вон оно что. А откуда тогда «Unterminated quoted string»?
По идее pee должен был бы попытаться выполнить команду ‘head с тремя аргументами -n1’, ‘tail и -n1’. Однако видно, что он пытается выполнить две команды.
Пишите правильно:
в консоли вку́пе (с чем-либо) в общем вообще |
в течение (часа) новичок нюанс по умолчанию |
приемлемо проблема пробовать трафик |
-
Bizdelnick
- Модератор
- Сообщения: 19825
- Статус: nulla salus bello
- ОС: Debian GNU/Linux
Re: кавычки в переменной
Сообщение
Bizdelnick » 28.09.2013 20:15
Да, точно, теперь дошло. Спасибо!
Пишите правильно:
в консоли вку́пе (с чем-либо) в общем вообще |
в течение (часа) новичок нюанс по умолчанию |
приемлемо проблема пробовать трафик |
-
drBatty
- Сообщения: 8735
- Статус: GPG ID: 4DFBD1D6 дом горит, козёл не видит…
- ОС: Slackware-current
- Контактная информация:
Re: кавычки в переменной
Сообщение
drBatty » 28.09.2013 20:16
Bizdelnick писал(а): ↑
28.09.2013 19:24
Интересует не решение конкретной проблемы (она уже решена совершенно другим путём), а именно причина ошибки.
а что такое pee?
ну а вообще — да, кавычки они являются самыми обычными символами ПОСЛЕ того, как оказались в переменной.
Код: Выделить всё
$ X=A"B
$ echo $X
A"B
$ Y=$X
$ echo $Y
A"B
Как видите, ДО того, как они завернулись, мне пришлось поставить бэкслэш.
Bizdelnick писал(а): ↑
28.09.2013 20:01
А, вон оно что. А откуда тогда «Unterminated quoted string»?
а вот это уже ваша pee видать таким образом распарсила свои параметры.
Hint: use set -x
-
drBatty
- Сообщения: 8735
- Статус: GPG ID: 4DFBD1D6 дом горит, козёл не видит…
- ОС: Slackware-current
- Контактная информация:
Re: кавычки в переменной
Сообщение
drBatty » 28.09.2013 20:42
Bizdelnick
а… Точно! Как же я забыл про мочу кошки!
Вот что думает по этому поводу гуглотранслятор:
Обратите внимание, что в то время как это похоже на тройник, копия вход не отправляется на стандартный вывод, как и тройник делает. Если это требуется, то используйте мочу кошки …
- Печать
Страницы: [1] Вниз
Тема: запуск пакета с расширением .run (Прочитано 2103 раз)
0 Пользователей и 1 Гость просматривают эту тему.

TAvol
Здравствуйте Все! Подскажите как решить проблему.
Ubuntu 14/04 Desktop. Скачал пакет с данным расширением, поставил галочку на исполнение, но через терминал с ‘sh‘ не запускается, пишет : Syntax error: «(» unexpected.
Загуглить не получается толком т.к. из-за спец знаков поисковой машины выдача дебильная получается.
Скачал с другого сайта другой пакет с .run, та же самая ошибка вылазит.
Скачал заведомо не подходящий по битности пакет, там выдало : Syntax error: Unterminated quoted string.
На одном сайте написали о необходимости установки вот этого:
Сделал, но результат тот же
Запускал инсталятор в режиме создания пакетов, та же ошибка.
Может есть у кого надумки?

БТР

TAvol
Только что получилось, хрен знает почему сразу не пошло, ведь делал все также.
Права 755 надо было поставить, хотя ставил и в первый раз….

Dt-13
Только что получилось, хрен знает почему сразу не пошло, ведь делал все также.
Права 755 надо было поставить, хотя ставил и в первый раз….
так после chmod… — проверить: ls — la.
Не остыл — в бане на вечно…
- Печать
Страницы: [1] Вверх