LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Scripting in C - need help (https://www.linuxquestions.org/questions/linux-newbie-8/scripting-in-c-need-help-702666/)

hifivoyager 02-06-2009 02:16 AM

Scripting in C - need help
 
I am trying to write up a script in C that, when run, e-mails me a message in banner format only if Friday is the 13th of the month. Please help!

ilikejam 02-06-2009 04:08 AM

If you have a specific need to do it in C, then fair enough, but this is a one-liner in cron, assuming sendmail/postfix/whatever is configured:

crontab:
0 9 13 * 5 /usr/bin/banner "Good luck" | /bin/mail -s "Friday" hifivoyager@emailprovider.com

Dave

johnsfine 02-06-2009 08:25 AM

Is there some reason to guess this thread is anything other than a "do my homework for me" request?

Assuming the thread is homework, hopefully those who know the answer will limit their responses to specific detail answers in response to more specific follow up questions from the OP (don't show off your C knowledge by posting the whole answer).

pixellany 02-06-2009 08:34 AM

C is not a scripting language....Please give some context for the question and confirm if it is homework.

johnsfine 02-06-2009 08:59 AM

Quote:

Originally Posted by pixellany (Post 3434164)
C is not a scripting language

C is a general purpose language. That includes scripting.

There are functions available to run another program, providing command line arguments and stdin to that program while capturing the exit code, stdout and stderr from that program. That plus some ordinary programming capabilities makes a scripting language. (I'm not making any comment there on whether it is a convenient scripting language).

Quote:

Please give some context for the question and confirm if it is homework.
A clearer problem statement would also help. I think Dave (ilikejam) misunderstood the problem statement (the required operation of the "script". I don't just mean that Dave intentionally ignored the specified language choice). Of course, if it is homework the OP probably can't give a clearer problem statement than the instructor gave to him.

Agrouf 02-06-2009 09:03 AM

Quote:

Originally Posted by johnsfine (Post 3434188)
C is a general purpose language. That includes scripting.

There are functions available to run another program, providing command line arguments and stdin to that program while capturing the exit code, stdout and stderr from that program. That plus some ordinary programming capabilities makes a scripting language. (I'm not making any comment there on whether it is a convenient scripting language).

I believe he meant that it is a compiled language. It is not a scripting language that you can use in an interpreter.

pixellany 02-06-2009 10:49 AM

OK---I stand corrected.

You can also put in wood screws with a sledgehammer, but noone would look at a sledgehammer and call it a screwdriver......;)

We can use the old definition of money: "Money" is anything that fulfills the function of money.

johnsfine 02-06-2009 01:16 PM

Quote:

Originally Posted by pixellany (Post 3434300)
You can also put in wood screws with a sledgehammer, but noone would look at a sledgehammer and call it a screwdriver......;)

I think a better viewpoint (and one of my favorite sayings) is:

There is a correct tool for every job, but I can't find it so I'm using a vise grip.

I have, in fact, used a vise grip to put in wood screws (it does a much better job than a sledgehammer) as well as take out a wider variety of screws, cut things, take corks out of wine bottles, etc.

C or C++ can fill that role very well in software engineering.

But in this thread, I was just trying to allow for the possibility that the OP's hypothetical instructor had given a reasonable assignment (do something in C as part of learning C, that might be better done some other way, but teaching something you ought to learn when learning C).

pixellany 02-06-2009 03:15 PM

You only ever need 2 tools:
1. If it moves, but is not supposed to: Duct Tape
2. If it supposed to move, but doesn't: WD-40

hifivoyager 02-06-2009 08:47 PM

Nope...
 
Quote:

Originally Posted by pixellany (Post 3434164)
C is not a scripting language....Please give some context for the question and confirm if it is homework.

It isnt a scripting language but it could be run as script. This is a prank I am doing to my co-workers from the IT department I work at. I want to send them an automated "scary message" every friday the 13th so that I dont have to manually write it every such day. got it?


All times are GMT -5. The time now is 07:22 PM.