I have a script that runs on boot. It basically takes some info, puts it into a text file, and then puts the text file on another box.
The line of code that produces the stty: standard input: Invalid argument error is
system("sudo -u username scp /tmp/bootbox21.txt mybox.mydomain:/export/home/username/");
I first though this was caused by sudo trying to run one of the .bashrc or .bash_profile files. In /etc/bashrc I commented out the two lines which have an stty command, but that didn't help. Actually I didn't think it would since, they're only run if it is a login shell. I then thought that ~/username/.bash_profile might have some problem. I eventually went so far as to completely rename it so it wouldn't be found. Still no luck.
So now I'm starting to wonder if it isn't some weird perl gotcha with the system command using sudo. Can anyone help with this?
to this:stty what ever ...
if [ -t 0 ]; then # only run if stdin is a terminal
stty what ever ...
fi
, and the problem will go away.
That message is coming from an "stty" command in your .bashrc (or whatever) on mybox.Ok I was afraid you'd say that. /etc/bashrc already has the terminal check in it. And removing the stty command doesn't help either.
There are the following files on the system
.bash_profile looks for .bashrc and then runs it. It also sets a couple of var including PATH and EDITOR and exports them.
.bashrc only looks for /etc/bashrc and then runs it.
/etc/bashrc has the stty commands but they only run if it is a terminal.
/etc/profile just sets some vars and runs stuff in
/etc/profile.d (all of which just set more vars)
There does not appear to be any other bash startup files used and only /etc/bashrc has an stty command.
So I'm still perplexed. It sounds like an stty command is still being executed eventhough it shouldn't be. I'm not even sure where to look for it.
As for what file is running it, just put an "echo TOP", "echo MIDDLE", and "echo BOTTOM" in the top, middle and bottom of your /etc/profile or whatever, and in whatever files he might call or source.
Move those echoes around to search for the stty in a binary fashion.
First thought is that sudo is looking for a password, which, by default, it gets from the terminal rather than stdin. Adding "-S" may help - but I would expect in this case that sudo would be failing for lack of password.
Why don't you try to use the Perl module for Sudo integration?
At least you would avoid the system call (and probably) the problem with stty (but I'm not sure about that).
perlmonks.org content © perlmonks.org and glasswalk3r, PreferredUserName, Tanktalus, xorl
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03