LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-06-2009, 02:16 AM   #1
hifivoyager
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
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!
 
Old 02-06-2009, 04:08 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
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
 
Old 02-06-2009, 08:25 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
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).
 
Old 02-06-2009, 08:34 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
C is not a scripting language....Please give some context for the question and confirm if it is homework.
 
Old 02-06-2009, 08:59 AM   #5
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by pixellany View Post
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.
 
Old 02-06-2009, 09:03 AM   #6
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Quote:
Originally Posted by johnsfine View Post
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.
 
Old 02-06-2009, 10:49 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
Old 02-06-2009, 01:16 PM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by pixellany View Post
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).
 
Old 02-06-2009, 03:15 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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
 
Old 02-06-2009, 08:47 PM   #10
hifivoyager
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Nope...

Quote:
Originally Posted by pixellany View Post
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I am new to scripting PKrishna Linux - Newbie 7 03-17-2008 09:39 PM
Help in scripting kkiwi8 Solaris / OpenSolaris 9 11-06-2007 07:37 PM
Need scripting help!! stan0934 Programming 5 05-29-2006 01:29 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
Need help with scripting xedios Linux - Software 1 07-29-2004 02:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration