Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am struggling the get my Cron Job working and suspect it is because I am not escaping a "%" in my password correctly. I know, it's bad to include pw etc, however, once this is working I will disable any inclusion of it anywhere external.
I should say I'm doing this from cPanel as I'm not a hard core Linux buff.
After many dozens of attempts, I am stumped. Here's what I'm trying to do.
Where "X" is password chars, "%" is included in pw and the backslash is my attempt to escape the % in the password.
Result (via email) is:
/usr/local/cpanel/bin/jailshell: -c: line 0: unexpected EOF while looking for matching `''
/usr/local/cpanel/bin/jailshell: -c: line 1: syntax error: unexpected end of file
Any help greatly appreciated
Last edited by Tempoetic; 05-17-2017 at 11:37 PM.
Reason: post left out backslash
Well, normally '\' should do it I would have thought .
Anyway, I would recommend putting all that into a shell script and just calling the script from cron.
Its more powerful/flexible and should also save you having to escape '%'.
PS: you could try double \\, but scripts are a better soln anyway.
It is not that simple. Cron runs using sh, and the command line interpreted differently. So putting everything in a script and running it with bash may definitely solve this issue (and also other similar ones).
I'm not really sure you need to protect % at all, there can be other problems.
You can try to create a shell/python/perl/awk/whatever script to print the passed command line arguments (just to check how cron handles your entry).
Also using cron you may need to take care about stdout and stderr yourself, probably there will be some other information (this is another reason to use a shell script - you can handle it better).
# mysql -p 'mypass'
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
# mysql -p'mypass'
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
see in the first how it says "using password: NO", having the space means prompt for password but I did not pass one, it assumes mypass is the name of the database now.
in the second, it actually passed mypass as the password but as that isn't my actual password it failed, still it says "using password: Yes" as 'mypass' is now seen as the password. you need to eliminate that space, mysqldump has the same behavior as the mysql client in this regards.
Last edited by r3sistance; 05-18-2017 at 03:24 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.