- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- ssh command within script gives "select: Invalid a...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 01:22 AM
тАО09-01-2005 01:22 AM
ssh command within script gives "select: Invalid argument" error.
I have written a script to keep a dmz'd ftp server synced with one behind a firewall. The script runs fine via command line but has problems with one of the commands when run from cron. The script runs on a sco box using rsync and ssh to connect to an hpux 11.11 system. Here is the command that fails:
if [ `ssh -l root hostname ls /$path/$to/$list | wc -l` -gt 0 ]
then
rsync ....
debugging info returns the following
select: Invalid argument
+ [ 0 -gt 0 ]
I've set PATH as well as sourcing /etc/profile and /root/.profile within the script. No luck. Scripting is not my forte. I would greatly appreciate any insight!
Thanks,
Eric
- Tags:
- ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 01:28 AM
тАО09-01-2005 01:28 AM
Re: ssh command within script gives "select: Invalid argument" error.
can you attach the script being kicked off via cron?
Have you also looked at getting some debug output from ssh to see that ssh isn't the problem...
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 01:32 AM
тАО09-01-2005 01:32 AM
Re: ssh command within script gives "select: Invalid argument" error.
Probably a path error from cron for the "ssh" command. Try using the full path to ssh.
Also, I generally surround the command string in an ssh command with "quotes" and have more sucess with that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 01:46 AM
тАО09-01-2005 01:46 AM
Re: ssh command within script gives "select: Invalid argument" error.
This is a known "feature" of earlier implementations of ssh, and usually the command is exected correctly (which is why ssh returns zero) so it's an irritant rather than a problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 01:53 AM
тАО09-01-2005 01:53 AM
Re: ssh command within script gives "select: Invalid argument" error.
instead of:
if [ `ssh -l root hostname ls /$path/$to/$list | wc -l` -gt 0 ]
then
rsync...
fi
how about...
if [ "$(ssh -l root hostname 'ls /path |wc -l' 2>/dev/null)" -gt 0 ]
then
rsync...
fi
Hope this helps,
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 02:03 AM
тАО09-01-2005 02:03 AM
Re: ssh command within script gives "select: Invalid argument" error.
Silly question of the week: When running from the command line, does your ssh ask for a password/phrase and/or is it using a ssh agent?
If so, you'll need to set up a null passphrased alternate identity, then change the ssh command to:
ssh -i ${alt_id} -l root ...
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 02:03 AM
тАО09-01-2005 02:03 AM
Re: ssh command within script gives "select: Invalid argument" error.
Thanks for the input thus far. ssh version is 3.0.2 on SCO. Attached is a modified script to protect the innocent. I'm trying Denver's suggestion now.
Thanks,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 02:13 AM
тАО09-01-2005 02:13 AM
Re: ssh command within script gives "select: Invalid argument" error.
I have public keys setup to allow ssh and rsync across without password/phrase. Denver, I tried your syntax but it looks like the script is just hanging there. I do see several errors in the dest. system's syslog:
sshd[2953]: error: getsockname failed: Invalid argument
Thoughts?
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 02:15 AM
тАО09-01-2005 02:15 AM
Re: ssh command within script gives "select: Invalid argument" error.
if you have an ssh-key that uses a passphrase, you need to cache the passprase w/ ssh-agent and tell the script to use the already running ssh-agent... or keep it simple and setup a key w/ out a passphrase and limit access of that key from directive s prepended to the key in .authorized_keys file.
so could be your orignal script was fine afterall, just failed in cron because it didn't use the ssh-agent you had running when the script was manually kicked off.
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 02:19 AM
тАО09-01-2005 02:19 AM
Re: ssh command within script gives "select: Invalid argument" error.
go back to your original script... do what doug said. :)
this: ssh -l root hostname
to this: ssh -i /path/to/your__passwordless_key -l root hostname
if all else fails, also use the "-vvv" w/the above ssh syntax change to see what's happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 02:19 AM
тАО09-01-2005 02:19 AM
Re: ssh command within script gives "select: Invalid argument" error.
Makes me think, Any firewalls in between?? The sshd by default listens to port 22. Is that port open in firewall??
Also you can run sshd -ddd and get more verbose details about error message.
Also as you are running through cron, make sure that you have all required variables set properly. Intentionally cron environment is very sparse.