Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Execution Limitation to non interactive ssh session
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
IgnitusBoyone
n00b
n00b


Joined: 13 Jun 2005
Posts: 24

PostPosted: Wed Jun 08, 2011 12:46 am    Post subject: Execution Limitation to non interactive ssh session Reply with quote

Ok, is there any obvious reason like security permissions why the following script would fail when executed over ssh with a supplied command

File updatecron.sh

Code:
#!/bin/bash
crontab -l > crontab.bak
cp crontab.bak crontab
echo " 30 2 * * * /usr/local/bin/targetprogram 2>&1" >> crontab
crontab crontab


This simple would be called using
Code:
ssh user@host updatecron.sh

The file was put in place prior to the attempt to run it remotly. Essentially I had over 100 servers I needed to hit with a crontab update, using a usr who doesn't have admin access. Now the script worked in an interactive ssh session just fine, but when ran as stated above in a non interactive mode it produced an empty cron file. I would understand no change, but instead it saved the previous cron to crontab.added the 3rd line to crontab and then saved an empty crontab to the users cron job erasing all previous cron jobs. I was thinking this has something to do with enviroment or not having the ability to run sbin apps, but I couldn't find anything on the internet.

If you have any feedback I would greatly appriciate it and if you have a better idea on how to automate commands like this when pushing to multiple servers I'm all ears.


Last edited by IgnitusBoyone on Wed Jun 08, 2011 2:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
feystorm
Tux's lil' helper
Tux's lil' helper


Joined: 29 Jan 2004
Posts: 96

PostPosted: Wed Jun 08, 2011 1:23 am    Post subject: Reply with quote

crontab -l > crontab.bak
cp crontab.back crontab

:wink:
Back to top
View user's profile Send private message
IgnitusBoyone
n00b
n00b


Joined: 13 Jun 2005
Posts: 24

PostPosted: Wed Jun 08, 2011 2:46 pm    Post subject: Reply with quote

Nice catch on the typo. I'm going to correct it in the post above. I was typing the script from memory which doesn't contain the same error, any other ideas?
Back to top
View user's profile Send private message
feystorm
Tux's lil' helper
Tux's lil' helper


Joined: 29 Jan 2004
Posts: 96

PostPosted: Thu Jun 09, 2011 12:27 am    Post subject: Reply with quote

I doubt any of those commands care about having a terminal available. However you can try ssh with '-tt' which will force creation of a tty on the remote end.
Back to top
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Thu Jun 09, 2011 8:28 am    Post subject: Reply with quote

Moved from Documentation, Tips & Tricks to Networking & Security as it's a support request.
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum