ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
I'm upgrading the firmware on some (200) IBM 7043-150 and 7043-170 workstations. I have two directories /ui/admin/fwupdate/170/170* and /ui/admin/fwupdate/150/150* which are NFS automounted. I am attempting to write an Expect script that will log in, su - to root run 'uname -M |cut -d"-" -f2' to get the w/s type (150 or 170), run 'lsmcode' to determine the firmware level and then echo "echo 1 | /ui/admin/fwupdate/150 or 170/150* or 170*" > /tmp/at_fwupdate, then run chmod u+x /tmp/at_fwupdate, then run at -f /tmp/fwupdate 0300 tomorrow and exit the w/s, continuing on to the next in my list created by variable set hostlist "list of hostnames here".
But...afer I 'expect "150"' or 'expect "170"'from the uname -M above, how do I take that output and make it a variable that I can do something with. Like if the workstation is a 150 model then run the 'lsmcode' and if the firmware is not 04195 then echo "echo 1 | {path to firmware upgrade" > /tmp/at_fwupdate, chmod u+x /tmp/at_fwupdate and create the atjob. Likewise for the 170 but if the firmware is not 05195 then do the echo.
Hope this makes sense, and hope you can help.
Wow, too hard to understand !
Try to reformulate your question leaving the specific commands aside. For example, we don't know what "echo 1 | /ui/admin/fwupdate/150" is supposed to do.
Can you cut down your problem until you get a couple of simple and objective bash questions ?
I'm using ksh, not bash on AIX 4.3.3. But this is an /usr/local/bin/expect script. Anyway I want my expect script to login as root to a host and check the machine type either IBM 7043-150 or 7043-170. Then I want it to run 'lsmcode' which checks the firmware level and the command returns not equal to either 04195 or 05195 I want it to echo "echo 1 | /ui/admin/fwupdate/150/150*" to a file called /tmp/at_fwupdate (if it's a 7043-150, change the 150 in the path to 170 for a 7043-170). Then I want to make the file executable "chmod u+x /tmp/at_fwupdate", and create an 'at' job to run at 0300 the next morning "at -f /tmp/at_fwupdate 0300 tomorrow".
My question is can I put 'if' statements in my expect script using the replies from 'uname -M' which determines machine type, and 'lsmcode' which determines the firmware level. This is not an AIX specific question, but rather an Expect scripting question.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.