Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all, my problem today is that i am trying to do a smart upgrade which SOMETIMES requires an input of y or n to upgrade the packages. I want this inside a script but am unsure on how to return the value when it calls for it. Obviously it will require an if statement to say if it requires a command give it the value. Someone mentioned the expect statement so I looked into that and I think it will look something like
expect "y/n"
send "y"
But the problem is if you do a smart upgrade it will ask for yes or no while its performing the upgrade so putting
smart upgrade
expect "y/n"
send "y"
isnt really going to work because it will execute the expect command after the smart upgrade has finished. Does anyone know how to get round this?
Thanks in advance.
When you "smart upgrade" if there any new packages it says "Confirm changes? (Y/n):" and expects a "y" or "n" to confirm changes. As I am trying to upgrade automatically every hour I want my script to reply "y" when it asks it to confirm changes. What I am trying to do is find a method that would do this sort of thing
If smart upgrade = "Confirm changes? (Y/n):" then return "y/r"
Sure, I have one. Scripting automatic software updates running as root that can change your system with no human intervention is a terrible idea, and a great way to completely bork your system without knowing why...
Is it really so difficult to check for updates once a day manually? Isn't 1/hour a bit excessive?
If not it is your system and you can do what you wish but I for one will not help you...
If I am misunderstanding what a "Smart upgrade" is do please tell.
Smart just downloads the latest updates, fixes dependencies and generally makes it a hell of a lot easier to install things. I suppose once an hour is a bit excessive but I want to make sure my system is up to date and I can't guarentee what time I'll be on linux. I'm sure there is a way of updating when you boot up, that will do. It isn't difficult to check manually every day for updates but it is a good training excercise to be able to do it. Thanks anyway, I'll wait for my books
It isn't difficult to check manually every day for updates but it is a good training excercise to be able to do it.
Ok, fair enough. But do please consider why it might be dangerous to blindly update software on your system.
I will say that 'expect' does seem to be exactly what you need. Have you read the documentation yet? From what you have written it seems you think of expect as a 'command' that you can use, but rather it is like a scripting language used to automate tasks that need user-intervention (like the spot you find yourself in).
It will execute the smart upgrade and only after it has finished it will run the expect statement. I have only put it this way because spawn doesnt work. Does anyone know another way to start a program and run the expect and send command half way through it? Thanks.
Try and invoke expect with the -d switch, it will tell you what's going on. I believe that the expect command will time out before smart asks for a confirmation, so inserting "set timeout -1" into your script should help.
This is quite dangerous really as it answers yes to anything smart upgrade asks so it's not really advisable but oh well, I'll just have to make a backup script too just in case. One problem with this is it seems to lock smart upgrade in read only mode. As I'll be changing the script to work on system boot this isn't a big problem thought. The other problem is I don't know how to save the output of this to a seperate file. I've tried
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.