could not change directory to “/home/corey/scripts”: Permission denied
I get the error message...
could not change directory to "/home/corey/scripts": Permission denied
... when I run the following script ...
#!/bin/bash
sudo -u postgres psql < setup_dev_db.sql
read -rsp $'Press any key to continue...n' -n 1 key
... the contents of setup_dev_db.sql are executed without any issues, but the error is annoying.
Can I get rid of it?
bash shell-script
add a comment |
I get the error message...
could not change directory to "/home/corey/scripts": Permission denied
... when I run the following script ...
#!/bin/bash
sudo -u postgres psql < setup_dev_db.sql
read -rsp $'Press any key to continue...n' -n 1 key
... the contents of setup_dev_db.sql are executed without any issues, but the error is annoying.
Can I get rid of it?
bash shell-script
2
Let's try to localize where the error is. If you typesudo -u postgres
, do you get the same error?
– Mark Plotnick
Sep 11 '15 at 14:40
@MarkPlotnick is on the right track. There are too many things going on with your script to easily identify WHICH is causing the problem. However, the quick check would be to review permissions for user postgres on the folder /home/corey/scripts
– 0xSheepdog
Sep 11 '15 at 14:48
1
I suspect it's simply because the OP ran the script from that directory, which thepostgres
user can't read, and the error would go away if the script was run from, say,/tmp
.
– roaima
Sep 11 '15 at 14:58
add a comment |
I get the error message...
could not change directory to "/home/corey/scripts": Permission denied
... when I run the following script ...
#!/bin/bash
sudo -u postgres psql < setup_dev_db.sql
read -rsp $'Press any key to continue...n' -n 1 key
... the contents of setup_dev_db.sql are executed without any issues, but the error is annoying.
Can I get rid of it?
bash shell-script
I get the error message...
could not change directory to "/home/corey/scripts": Permission denied
... when I run the following script ...
#!/bin/bash
sudo -u postgres psql < setup_dev_db.sql
read -rsp $'Press any key to continue...n' -n 1 key
... the contents of setup_dev_db.sql are executed without any issues, but the error is annoying.
Can I get rid of it?
bash shell-script
bash shell-script
asked Sep 11 '15 at 14:36
CoreyCorey
203512
203512
2
Let's try to localize where the error is. If you typesudo -u postgres
, do you get the same error?
– Mark Plotnick
Sep 11 '15 at 14:40
@MarkPlotnick is on the right track. There are too many things going on with your script to easily identify WHICH is causing the problem. However, the quick check would be to review permissions for user postgres on the folder /home/corey/scripts
– 0xSheepdog
Sep 11 '15 at 14:48
1
I suspect it's simply because the OP ran the script from that directory, which thepostgres
user can't read, and the error would go away if the script was run from, say,/tmp
.
– roaima
Sep 11 '15 at 14:58
add a comment |
2
Let's try to localize where the error is. If you typesudo -u postgres
, do you get the same error?
– Mark Plotnick
Sep 11 '15 at 14:40
@MarkPlotnick is on the right track. There are too many things going on with your script to easily identify WHICH is causing the problem. However, the quick check would be to review permissions for user postgres on the folder /home/corey/scripts
– 0xSheepdog
Sep 11 '15 at 14:48
1
I suspect it's simply because the OP ran the script from that directory, which thepostgres
user can't read, and the error would go away if the script was run from, say,/tmp
.
– roaima
Sep 11 '15 at 14:58
2
2
Let's try to localize where the error is. If you type
sudo -u postgres
, do you get the same error?– Mark Plotnick
Sep 11 '15 at 14:40
Let's try to localize where the error is. If you type
sudo -u postgres
, do you get the same error?– Mark Plotnick
Sep 11 '15 at 14:40
@MarkPlotnick is on the right track. There are too many things going on with your script to easily identify WHICH is causing the problem. However, the quick check would be to review permissions for user postgres on the folder /home/corey/scripts
– 0xSheepdog
Sep 11 '15 at 14:48
@MarkPlotnick is on the right track. There are too many things going on with your script to easily identify WHICH is causing the problem. However, the quick check would be to review permissions for user postgres on the folder /home/corey/scripts
– 0xSheepdog
Sep 11 '15 at 14:48
1
1
I suspect it's simply because the OP ran the script from that directory, which the
postgres
user can't read, and the error would go away if the script was run from, say, /tmp
.– roaima
Sep 11 '15 at 14:58
I suspect it's simply because the OP ran the script from that directory, which the
postgres
user can't read, and the error would go away if the script was run from, say, /tmp
.– roaima
Sep 11 '15 at 14:58
add a comment |
4 Answers
4
active
oldest
votes
To change to a directory, a user must have the 'x' permission for that directory.
I assume you are running the script from '/home/corey/scripts'. When 'sudo -u postgres' changes the current user to 'postgres' it attempts to set the working directory for 'postgres' to the working directory it was called from generating the error you're seeing.
Make sure that the user 'postgres' has permission 'x' for '/home/corey/scripts'.
I added "cd /tmp" to the top of my file and prefixed "setup_dev_db.sql" with "~/Dropbox/scripts/" and that fixed it.
– Corey
Sep 15 '15 at 15:24
add a comment |
Postgres wants to create a $HOME/.psql_history
file, where it will store all your queries and commands from the psql
client. It may well want to do something else at $HOME
, but I don't see any evidence in the form of other hidden files. And it won't actually create the history file unless you're using psql
interactively, which you're not.
I had this exact same problem and found this question, but the accepted answer wasn't acceptable to me -- I shouldn't have to grant postgres permission to leave a trail of my queries in whatever directory I happen to be in when I run a script!
@Corey, the solution you mentioned in your comment (cd /tmp
before calling sudo...
) is probably the best. psql
won't create this file in /tmp
(I'm sure that's deliberate, because it could allow unprivileged users to read the file).
There are two other solutions I can think of :
Run
psql
in a login shell by adding-i
to your command
sudo -i -u postgres psql < setup_dev_db.sql
This will set
$HOME
topostgres
'sHOME
directory, listed in/etc/passwd
. For Ubuntu, that's/var/lib/postgres
. But since you're piping in commands, it won't create a.psql_history
file. However, if you use interactivepsql
, anyone else withsudo
privileges on the machine will have access to your command history.
I'm not sure if there are any other negative consequences to running a login shell in this situation.
Run
psql
as a less-privileged user, e.g.
$ psql dev_db -hlocalhost corey_dev -W < setup_dev_db.sql
If this is a problem because you leave postgres user creation to your
setup_dev_db.sql
script, and you don't have any users yet, just add acreateuser
command in your script first, something like this:
$ sudo -u postgres createuser corey_dev -P
and perhaps ...
$ sudo -u postgres createdb dev_db "Dev database"
NOTE: When using the psql
client interactively (which you're not, here), if you see a message like could not change directory to "/home/corey/scripts": Permission denied
message ****, psql
is going to write to /var/lib/postgres/.psql_history
(or wherever its $HOME
is)! If you've ever seen that warning when using interactive psql
, go look--you'll probably find a hidden history file.
add a comment |
You may use sudo -u postgres -c your_command.bash
or su postgres -c your_command.bash
.
You could also use,
su - postgres your_command.bash
This will ensure that you acquired all the postgres account enviroment.
won't work if you don't want everything in the script to run as root...
– Lambart
Oct 6 '17 at 7:17
add a comment |
For me this did the trick, pay attention to quotes (')
sudo -Hiu postgres 'pg_dump --column-inserts --data-only --table=someTable entities_db > /var/backups/anywhere/$(date +%Y%m%d_%H%M%S)_someTable.sql'
Note the -Hiu
for sudo, or use su - postgres
you can also put that in a cronjob for root with crontab -e
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f229069%2fcould-not-change-directory-to-home-corey-scripts-permission-denied%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
To change to a directory, a user must have the 'x' permission for that directory.
I assume you are running the script from '/home/corey/scripts'. When 'sudo -u postgres' changes the current user to 'postgres' it attempts to set the working directory for 'postgres' to the working directory it was called from generating the error you're seeing.
Make sure that the user 'postgres' has permission 'x' for '/home/corey/scripts'.
I added "cd /tmp" to the top of my file and prefixed "setup_dev_db.sql" with "~/Dropbox/scripts/" and that fixed it.
– Corey
Sep 15 '15 at 15:24
add a comment |
To change to a directory, a user must have the 'x' permission for that directory.
I assume you are running the script from '/home/corey/scripts'. When 'sudo -u postgres' changes the current user to 'postgres' it attempts to set the working directory for 'postgres' to the working directory it was called from generating the error you're seeing.
Make sure that the user 'postgres' has permission 'x' for '/home/corey/scripts'.
I added "cd /tmp" to the top of my file and prefixed "setup_dev_db.sql" with "~/Dropbox/scripts/" and that fixed it.
– Corey
Sep 15 '15 at 15:24
add a comment |
To change to a directory, a user must have the 'x' permission for that directory.
I assume you are running the script from '/home/corey/scripts'. When 'sudo -u postgres' changes the current user to 'postgres' it attempts to set the working directory for 'postgres' to the working directory it was called from generating the error you're seeing.
Make sure that the user 'postgres' has permission 'x' for '/home/corey/scripts'.
To change to a directory, a user must have the 'x' permission for that directory.
I assume you are running the script from '/home/corey/scripts'. When 'sudo -u postgres' changes the current user to 'postgres' it attempts to set the working directory for 'postgres' to the working directory it was called from generating the error you're seeing.
Make sure that the user 'postgres' has permission 'x' for '/home/corey/scripts'.
answered Sep 11 '15 at 15:27
robartsdrobartsd
1455
1455
I added "cd /tmp" to the top of my file and prefixed "setup_dev_db.sql" with "~/Dropbox/scripts/" and that fixed it.
– Corey
Sep 15 '15 at 15:24
add a comment |
I added "cd /tmp" to the top of my file and prefixed "setup_dev_db.sql" with "~/Dropbox/scripts/" and that fixed it.
– Corey
Sep 15 '15 at 15:24
I added "cd /tmp" to the top of my file and prefixed "setup_dev_db.sql" with "~/Dropbox/scripts/" and that fixed it.
– Corey
Sep 15 '15 at 15:24
I added "cd /tmp" to the top of my file and prefixed "setup_dev_db.sql" with "~/Dropbox/scripts/" and that fixed it.
– Corey
Sep 15 '15 at 15:24
add a comment |
Postgres wants to create a $HOME/.psql_history
file, where it will store all your queries and commands from the psql
client. It may well want to do something else at $HOME
, but I don't see any evidence in the form of other hidden files. And it won't actually create the history file unless you're using psql
interactively, which you're not.
I had this exact same problem and found this question, but the accepted answer wasn't acceptable to me -- I shouldn't have to grant postgres permission to leave a trail of my queries in whatever directory I happen to be in when I run a script!
@Corey, the solution you mentioned in your comment (cd /tmp
before calling sudo...
) is probably the best. psql
won't create this file in /tmp
(I'm sure that's deliberate, because it could allow unprivileged users to read the file).
There are two other solutions I can think of :
Run
psql
in a login shell by adding-i
to your command
sudo -i -u postgres psql < setup_dev_db.sql
This will set
$HOME
topostgres
'sHOME
directory, listed in/etc/passwd
. For Ubuntu, that's/var/lib/postgres
. But since you're piping in commands, it won't create a.psql_history
file. However, if you use interactivepsql
, anyone else withsudo
privileges on the machine will have access to your command history.
I'm not sure if there are any other negative consequences to running a login shell in this situation.
Run
psql
as a less-privileged user, e.g.
$ psql dev_db -hlocalhost corey_dev -W < setup_dev_db.sql
If this is a problem because you leave postgres user creation to your
setup_dev_db.sql
script, and you don't have any users yet, just add acreateuser
command in your script first, something like this:
$ sudo -u postgres createuser corey_dev -P
and perhaps ...
$ sudo -u postgres createdb dev_db "Dev database"
NOTE: When using the psql
client interactively (which you're not, here), if you see a message like could not change directory to "/home/corey/scripts": Permission denied
message ****, psql
is going to write to /var/lib/postgres/.psql_history
(or wherever its $HOME
is)! If you've ever seen that warning when using interactive psql
, go look--you'll probably find a hidden history file.
add a comment |
Postgres wants to create a $HOME/.psql_history
file, where it will store all your queries and commands from the psql
client. It may well want to do something else at $HOME
, but I don't see any evidence in the form of other hidden files. And it won't actually create the history file unless you're using psql
interactively, which you're not.
I had this exact same problem and found this question, but the accepted answer wasn't acceptable to me -- I shouldn't have to grant postgres permission to leave a trail of my queries in whatever directory I happen to be in when I run a script!
@Corey, the solution you mentioned in your comment (cd /tmp
before calling sudo...
) is probably the best. psql
won't create this file in /tmp
(I'm sure that's deliberate, because it could allow unprivileged users to read the file).
There are two other solutions I can think of :
Run
psql
in a login shell by adding-i
to your command
sudo -i -u postgres psql < setup_dev_db.sql
This will set
$HOME
topostgres
'sHOME
directory, listed in/etc/passwd
. For Ubuntu, that's/var/lib/postgres
. But since you're piping in commands, it won't create a.psql_history
file. However, if you use interactivepsql
, anyone else withsudo
privileges on the machine will have access to your command history.
I'm not sure if there are any other negative consequences to running a login shell in this situation.
Run
psql
as a less-privileged user, e.g.
$ psql dev_db -hlocalhost corey_dev -W < setup_dev_db.sql
If this is a problem because you leave postgres user creation to your
setup_dev_db.sql
script, and you don't have any users yet, just add acreateuser
command in your script first, something like this:
$ sudo -u postgres createuser corey_dev -P
and perhaps ...
$ sudo -u postgres createdb dev_db "Dev database"
NOTE: When using the psql
client interactively (which you're not, here), if you see a message like could not change directory to "/home/corey/scripts": Permission denied
message ****, psql
is going to write to /var/lib/postgres/.psql_history
(or wherever its $HOME
is)! If you've ever seen that warning when using interactive psql
, go look--you'll probably find a hidden history file.
add a comment |
Postgres wants to create a $HOME/.psql_history
file, where it will store all your queries and commands from the psql
client. It may well want to do something else at $HOME
, but I don't see any evidence in the form of other hidden files. And it won't actually create the history file unless you're using psql
interactively, which you're not.
I had this exact same problem and found this question, but the accepted answer wasn't acceptable to me -- I shouldn't have to grant postgres permission to leave a trail of my queries in whatever directory I happen to be in when I run a script!
@Corey, the solution you mentioned in your comment (cd /tmp
before calling sudo...
) is probably the best. psql
won't create this file in /tmp
(I'm sure that's deliberate, because it could allow unprivileged users to read the file).
There are two other solutions I can think of :
Run
psql
in a login shell by adding-i
to your command
sudo -i -u postgres psql < setup_dev_db.sql
This will set
$HOME
topostgres
'sHOME
directory, listed in/etc/passwd
. For Ubuntu, that's/var/lib/postgres
. But since you're piping in commands, it won't create a.psql_history
file. However, if you use interactivepsql
, anyone else withsudo
privileges on the machine will have access to your command history.
I'm not sure if there are any other negative consequences to running a login shell in this situation.
Run
psql
as a less-privileged user, e.g.
$ psql dev_db -hlocalhost corey_dev -W < setup_dev_db.sql
If this is a problem because you leave postgres user creation to your
setup_dev_db.sql
script, and you don't have any users yet, just add acreateuser
command in your script first, something like this:
$ sudo -u postgres createuser corey_dev -P
and perhaps ...
$ sudo -u postgres createdb dev_db "Dev database"
NOTE: When using the psql
client interactively (which you're not, here), if you see a message like could not change directory to "/home/corey/scripts": Permission denied
message ****, psql
is going to write to /var/lib/postgres/.psql_history
(or wherever its $HOME
is)! If you've ever seen that warning when using interactive psql
, go look--you'll probably find a hidden history file.
Postgres wants to create a $HOME/.psql_history
file, where it will store all your queries and commands from the psql
client. It may well want to do something else at $HOME
, but I don't see any evidence in the form of other hidden files. And it won't actually create the history file unless you're using psql
interactively, which you're not.
I had this exact same problem and found this question, but the accepted answer wasn't acceptable to me -- I shouldn't have to grant postgres permission to leave a trail of my queries in whatever directory I happen to be in when I run a script!
@Corey, the solution you mentioned in your comment (cd /tmp
before calling sudo...
) is probably the best. psql
won't create this file in /tmp
(I'm sure that's deliberate, because it could allow unprivileged users to read the file).
There are two other solutions I can think of :
Run
psql
in a login shell by adding-i
to your command
sudo -i -u postgres psql < setup_dev_db.sql
This will set
$HOME
topostgres
'sHOME
directory, listed in/etc/passwd
. For Ubuntu, that's/var/lib/postgres
. But since you're piping in commands, it won't create a.psql_history
file. However, if you use interactivepsql
, anyone else withsudo
privileges on the machine will have access to your command history.
I'm not sure if there are any other negative consequences to running a login shell in this situation.
Run
psql
as a less-privileged user, e.g.
$ psql dev_db -hlocalhost corey_dev -W < setup_dev_db.sql
If this is a problem because you leave postgres user creation to your
setup_dev_db.sql
script, and you don't have any users yet, just add acreateuser
command in your script first, something like this:
$ sudo -u postgres createuser corey_dev -P
and perhaps ...
$ sudo -u postgres createdb dev_db "Dev database"
NOTE: When using the psql
client interactively (which you're not, here), if you see a message like could not change directory to "/home/corey/scripts": Permission denied
message ****, psql
is going to write to /var/lib/postgres/.psql_history
(or wherever its $HOME
is)! If you've ever seen that warning when using interactive psql
, go look--you'll probably find a hidden history file.
edited Oct 6 '17 at 16:44
answered Oct 6 '17 at 8:02
LambartLambart
26218
26218
add a comment |
add a comment |
You may use sudo -u postgres -c your_command.bash
or su postgres -c your_command.bash
.
You could also use,
su - postgres your_command.bash
This will ensure that you acquired all the postgres account enviroment.
won't work if you don't want everything in the script to run as root...
– Lambart
Oct 6 '17 at 7:17
add a comment |
You may use sudo -u postgres -c your_command.bash
or su postgres -c your_command.bash
.
You could also use,
su - postgres your_command.bash
This will ensure that you acquired all the postgres account enviroment.
won't work if you don't want everything in the script to run as root...
– Lambart
Oct 6 '17 at 7:17
add a comment |
You may use sudo -u postgres -c your_command.bash
or su postgres -c your_command.bash
.
You could also use,
su - postgres your_command.bash
This will ensure that you acquired all the postgres account enviroment.
You may use sudo -u postgres -c your_command.bash
or su postgres -c your_command.bash
.
You could also use,
su - postgres your_command.bash
This will ensure that you acquired all the postgres account enviroment.
answered Oct 5 '17 at 11:38
George SiggouroglouGeorge Siggouroglou
1115
1115
won't work if you don't want everything in the script to run as root...
– Lambart
Oct 6 '17 at 7:17
add a comment |
won't work if you don't want everything in the script to run as root...
– Lambart
Oct 6 '17 at 7:17
won't work if you don't want everything in the script to run as root...
– Lambart
Oct 6 '17 at 7:17
won't work if you don't want everything in the script to run as root...
– Lambart
Oct 6 '17 at 7:17
add a comment |
For me this did the trick, pay attention to quotes (')
sudo -Hiu postgres 'pg_dump --column-inserts --data-only --table=someTable entities_db > /var/backups/anywhere/$(date +%Y%m%d_%H%M%S)_someTable.sql'
Note the -Hiu
for sudo, or use su - postgres
you can also put that in a cronjob for root with crontab -e
add a comment |
For me this did the trick, pay attention to quotes (')
sudo -Hiu postgres 'pg_dump --column-inserts --data-only --table=someTable entities_db > /var/backups/anywhere/$(date +%Y%m%d_%H%M%S)_someTable.sql'
Note the -Hiu
for sudo, or use su - postgres
you can also put that in a cronjob for root with crontab -e
add a comment |
For me this did the trick, pay attention to quotes (')
sudo -Hiu postgres 'pg_dump --column-inserts --data-only --table=someTable entities_db > /var/backups/anywhere/$(date +%Y%m%d_%H%M%S)_someTable.sql'
Note the -Hiu
for sudo, or use su - postgres
you can also put that in a cronjob for root with crontab -e
For me this did the trick, pay attention to quotes (')
sudo -Hiu postgres 'pg_dump --column-inserts --data-only --table=someTable entities_db > /var/backups/anywhere/$(date +%Y%m%d_%H%M%S)_someTable.sql'
Note the -Hiu
for sudo, or use su - postgres
you can also put that in a cronjob for root with crontab -e
answered Jan 11 at 10:30
Philippe GachoudPhilippe Gachoud
445310
445310
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f229069%2fcould-not-change-directory-to-home-corey-scripts-permission-denied%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Let's try to localize where the error is. If you type
sudo -u postgres
, do you get the same error?– Mark Plotnick
Sep 11 '15 at 14:40
@MarkPlotnick is on the right track. There are too many things going on with your script to easily identify WHICH is causing the problem. However, the quick check would be to review permissions for user postgres on the folder /home/corey/scripts
– 0xSheepdog
Sep 11 '15 at 14:48
1
I suspect it's simply because the OP ran the script from that directory, which the
postgres
user can't read, and the error would go away if the script was run from, say,/tmp
.– roaima
Sep 11 '15 at 14:58