Impossible to get output of remote ssh commands via cron
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎05-13-2016 11:08 AM
Hello,
I have made a bash script to get ipstats of several devices, and i have a problem with my X450a-48t, the script works fine if i execute it manually, but in crontab no output, i think because in cron no tty is allocated.
Example script:
#!/bin/bash
ssh -o "StrictHostKeyChecking no" admin@10.26.196.189 "show ipstats"
i have checked ssh with -t and -tt option, but doesn't work.
¿Any idea how to solve it? ¿another possibility to get this stats remotely?
Regards,
Ivan
I have made a bash script to get ipstats of several devices, and i have a problem with my X450a-48t, the script works fine if i execute it manually, but in crontab no output, i think because in cron no tty is allocated.
Example script:
#!/bin/bash
ssh -o "StrictHostKeyChecking no" admin@10.26.196.189 "show ipstats"
i have checked ssh with -t and -tt option, but doesn't work.
¿Any idea how to solve it? ¿another possibility to get this stats remotely?
Regards,
Ivan
13 REPLIES 13
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎07-09-2016 01:08 PM
Hello Bart,
which version of EXOS do you use? In my testing older firmware versions did not work, while newer did.
Did you try to run your script with /dev/null as STDIN from a terminal window? That resulted in the same problem as running the command from cron for me.
$ my_script HTH,
Erik
which version of EXOS do you use? In my testing older firmware versions did not work, while newer did.
Did you try to run your script with /dev/null as STDIN from a terminal window? That resulted in the same problem as running the command from cron for me.
$ my_script HTH,
Erik
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎07-09-2016 01:08 PM
Hi,
I have used the following simple script just to test the switch behavior with SSH via expect. The switches had my SSH key configured for admin access. The switch IP address needs to be adjusted, of course.
#! /usr/bin/expect -f spawn ssh admin@192.0.2.11 expect { {# } {send "show version\r"} } expect { {# } {send "exit\r"} }The expect script waits for the switch prompt (login w/o password handled via SSH), issues the command "show version", and logs off the switch after detecting the prompt again.
Br,
Erik
I have used the following simple script just to test the switch behavior with SSH via expect. The switches had my SSH key configured for admin access. The switch IP address needs to be adjusted, of course.
#! /usr/bin/expect -f spawn ssh admin@192.0.2.11 expect { {# } {send "show version\r"} } expect { {# } {send "exit\r"} }The expect script waits for the switch prompt (login w/o password handled via SSH), issues the command "show version", and logs off the switch after detecting the prompt again.
Br,
Erik
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎07-09-2016 01:08 PM
Bart,
I'm not in the office today, but I plan to add the script to this thread tomorrow.
Erik
I'm not in the office today, but I plan to add the script to this thread tomorrow.
Erik
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎07-09-2016 01:08 PM
Erik,
Thanks for the info. I'll look into expect perl modules. Can you provide the simple script you tested today so I can verify results?
Bart
Thanks for the info. I'll look into expect perl modules. Can you provide the simple script you tested today so I can verify results?
Bart
