Need help creating shell script with output that has 2014 calendar and 2 text items from a"fortune"
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am required to create a bash shell script with either emacs or vi. It must include the year 2014 calendar on the left side and two text items on the right side.
2. Relevant commands, code, scripts, algorithms:
the two text items are from what my professor describes as a "fortune server". I have two commands to query them. nc langley.cs.fsu.edu 19000 and " " 19001. I am also instructed that the 2014 calendar must be computed and not a fixed value of 2014. I am told to use d=`date '+%Y'` to get the current year, then told to use the Bash syntax $((++d)). I am then recommended to use pr to paste the output together with pr -t -T -m -w 140 file1 file2.
3. The attempts at a solution (include all code and scripts):
It seems to take the d=`date '+%Y'` but then when i go to Bash and type $((++d)) it says 2014:command not found.
I also don't understand how to paste the two text items into individual files in order to put them together in a single script
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
FSU,Tallahassee, FL, USA, Langley, COP3353
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
So does that mean I have to input the d=`date '+%Y'` into emacs? Also once it's in emacs am I supposed to be putting parentheses around the commands to make them work?
Also here is a link to the assignment, this was left off of the original post.
www dot cs dot fsu dot edu slash ~langley slash COP3353 slash 2013-2 slash Assignment02 dot html
(Had to add "dot" "slash" since I'm too noob to post urls, sorry)
Well we are not going to do the work for you, you know that hum...
You seem to be quite lost ( were you listening during the course? ...) English is a second language for me so Im very cautious when it comes to understand assignments... not the same thing as to solve issues...
My understanding is that you are NOT to put in your shell script what you think but it is the expected output of the execution of your script: Not the same thing...
So the script you are to write has to produce for output the claendar 2014 on the left and the output of 2 files on the right,the pr code sample is a sample to me ... you may need to adapt...
Last edited by vbe; 07-02-2013 at 10:03 AM..
Reason: typos sorry i thinkmy dislexya is playing with me again...
bash isnt necessary but recommended by your instructor ( I still use ksh or true sh ...)
and I use vi...
this is the wanted output:
Here are some tools that you can use to do the assignment:
The left hand side is generated by the program cal.
The two text items on the right hand side are from a "fortune server" that you can query at nc langley.cs.fsu.edu 19000 and at nc langley.cs.fsu.edu 19001.
To create names for temporary files, you can use the program mktemp.
To get the current year, you can use d=`date '+%Y'`; to increase the year, you can use the Bash syntax $((++d))
To paste the output together horizontally from these programs, I recommend using pr (and not paste) like pr -t -T -m -w 140 file1 file2
This is your instructor's "pseudocode" on how he wrote the script, and so what you are asked to write:
You have now ( and we also hehe...) all the information needed to do the given task, start by copying this script, it will serve you as template and documentation, try to write the calendar part, as written:
# Create a temporary file for the calendar.
# Get the year from "date".
# Increase the year by one and then call the "cal" program with that year. Write the
# output to the temporary calendar file.
Show us the result, then if OK we pass to the next part...
Quote:
I have two commands to query them:
nc langley.cs.fsu.edu 19000 and " " 19001.
the output of the command is to be saved as file1 file2 for the right side output of your script...
Yes I don't expect anyone to do the work for me. I was adding the link since I thought I was explaining the assignment poorly. I am quite lost, the professor assumes everyone knows how to do basic commands to start but I don't. I am not a computer science student. This was supposed to be an easy elective class, boy they fooled me! Thanks anyways for the attempt to help. I think I'll just try and see what happens.
Look at my updated last post:
Start by doing the calendar part:
When you dont know what to do, you try simple instructions... look at my first post thenlook at the output of cal 2013 doesnt that inspire you? Do you see now the reason of the temporary file ? ( save the output...)
Get that working and we will see next step...
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Which one of the following are more accurate and why?
nohup myScript.sh 1>nohup_$(date +%Y%m%d%H%M%S).out 2>&1 &
nohup myScript.sh 1>>nohup_$(date +%Y%m%d%H%M%S).out 2>&1 &
nohup myScript.sh >nohup_$(date +%Y%m%d%H%M%S).out 2>&1 &
nohup myScript.sh >>nohup_$(date +%Y%m%d%H%M%S).out 2>&1 &... (3 Replies)
How do I create shortcuts? For example:
I just want to type one key "l" and have it output the command of "ls -lah"
I believe it's creating a file called l with 755 permissions but I'm not sure where to put the file.
*if it matters, I'm on a shared hosting web server using cPanel with... (2 Replies)
Hi All,
I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations:
1. I am restrained to 2 input files only.
2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Hello,
I'm trying to create a VirtualBox "harddisk" and put an dd-image into it. This image shoudn't work as a virtual maschine, I just want to be able to mount it to an folder. How can I do this with an shell script?
Sebi
---------- Post updated at 10:36 AM ---------- Previous update... (0 Replies)
Hi,
This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Hallo,
i need a Prompting read in my script:
read -p "Enter your command: " command
But i always get this Error:
-p: is not an identifier
When I run these in c-shell i get this error
/usr/bin/read: read: bad option(s)
How can I use a Prompt in the read command? (9 Replies)
Hello,
I need to capture everything showed on a screen by a shell script which needs user interaction. The shell script performs commads such as rsh so normal redirection to a file does not work.
I know there is a special unix command call "script" which records screen session but the... (4 Replies)
Hi,
I have had a problem in Linux with the "Fortune" messages (unfortunately! :( ) and I need to trap the message again. It starts with a "IMPORTANT NOTICE".
To capture this, I write a script as follows..
#!/bin/sh
a=0
while ; do
/usr/games/fortune >> fortune.txt
a=`expr $a + 1`
done... (4 Replies)