Changes

Jump to: navigation, search

Talk:Fall 2008 SPR720 Sample Exam Questions

2,116 bytes added, 09:20, 11 December 2008
no edit summary
Here are some sample questions to aid you in exam preparation. '''Feel free to discuss the answers on the ''discussion'' page (see link above).'''
===1. What will the output of this script be?===
#!/bin/bash
done
===ANSWER:===
<pre>
ireland
Nes
===2. What will the output of this script be?===
#!/bin/bash
done
===ANSWER:===
<pre>
one three
===3. What will the output of this script be?===
#!/bin/bash
echo "exrxzW" | tr "A/blCedxEzfrGyhoI=JW" "8qC3pSDehcTngi#TNrIa"
===ANSWER:===
<pre>
Seneca
# say, if u pipe is "A/B", then out put is "8qC", if the pipe is "ACxEW", then output will be "8peha"
===4. What will the output of this script be?===
#!/bin/bash
done
===ANSWER:===
<pre>
0^2= 0
Nes
===5. Here is a Makefile:===
a: b c
If the command "make d" is entered, what commands will ''make'' execute? Explain why.
ANSWER
<pre>
It will call up the function "d" in Makefile, and function "d" will call-up function "a", then function "a" will run print out the content of file "b" and "c" into a file called "a"
then, at the end of function "d", it will tar (with compress) file "a" to a tar file called "e"
 
</pre>
6. Write a python script which will ask the user for '''Why? -- There is something that specifically triggers the name of target 'a virtual machine and report whether that virtual machine is running' .. (Use libvirt).also, careful with terminology, use 'target' and 'dependency' -CT'''
Nes ===6. Write a python script which will ask the user for the name of a virtual machine and report whether that virtual machine is running. (Use libvirt).===ANSWER<pre> #!/usr/bin/python import libvirt vm_Name=str(raw_input("Please enter your virtual machine's name: "))conn=libvirt.open(None)try: vm=conn.lookupByName(vm_Name) try: vm_id=vm.ID() print "Yes, your vm is up and running. The ID is ", vm_id except: print "Your vm is defined, but not running." except: print "Sorry, your vm is not running." </pre>Nes.. finally.. i did it.. @@Nes: edit at 00:53, as CT suggested. ===7. Write a bash script which will print all of the files in your home directory which end in .ps -- you must be able to run the script from any directory.===<PRE> #!/bin/bashfind ~ -name "*.ps" Save the script, give it executabel permission. PATH="$PATH:."</pre> '''Actually, I meant print as in send them to the printer. -CT'''
8. Write a spec file for an RPM package. Here are the package details:
13. What command would you use to set the permission on a script so that only the script's owner could execute it? All other users should have no access to the script.
===14. Write the correct bash syntax to run the command "foo", taking the input from the file "hot", placing the output in the file "cold", and placing error message in the file "warm".===ANSWER: cat < hot > cold 2>warm (I use cat instead of "foo") ''PopCon'' ===15. Write the correct bash syntax to run the command "bar", taking the input from the file "up", and sending the output and error messages to the command "baz".=== cat < up > baz 2>&1 (again I use cat instead of "bar") ''PopCon''
15===16. Write the correct a bash syntax script to run the command "bar", taking display all of the input odd numbers from the file "up", and sending the output and error messages 1 to the command 99 with one space between each number.===ANSWER: #!/bin/bash for ((A=1; A<=99; A+=2)) do echo -n $A"baz". done
16. Write a bash script to display all of the odd numbers from 1 to 99 with one space between each number.''PopCon''
===17. Describe what the PATH environment variable does. Write the syntax to add the directory "/usr/local/bin" to the PATH as the first directory searched.===ANSWER:Nes: PATH is a variable that tell where the shell what path to search when a command was requested to run. <pre>PATH=$PATH:/usr/local/bin</pre>
===18. What will this command do to the existing file "ocean"? date >ocean=== Answer <pre>Nes: It will redirect standard output of command "date" to the file "ocean". The file "ocean" iwll be replaced.</pre>===19. What will this command do to the existing file "sea"? date >>sea===
19. What Answer<pre>Nes: It will this redirect standard output of command do "date" and append to the existing file "sea"? date >. The newer output will be writen at the end of the file "sea".</Pre>sea
=== 20. What will this command do if the file "lake" does not exist? date >lake=== Nes: The command will redirect the standard output of command "date" into a new created file "lake"
=== 21. What will this command do if the file "stream" does not exist? lpr <stream===Nes: It will capture standard output and save it to the file "stream", then the command "lpr" will put it in the print queue.
22. What is wrong with this command pipeline? How would you fix it? cat /usr/share/dict/words >/tmp/x | grep -i "[aeiou]" <<wc | wc -l
23. Write a bash script which asks the user for a one-line message and an e-mail address, then converts the message to uppercase and mails it to the address specified.

Navigation menu