ICMAKE Part 4
#! /usr/local/bin/icmake -qi
/*
This script is used to implement a non-destructive rm
*/
#define YEAR "1993, 1994"
#define VERSION "1.10"
int
flags_done,
extract,
viewmode,
debug;
string
home,
attic,
cwd,
progname,
recurs,
forced,
unzipflag;
void kill(string s)
{
printf(s, "\n\n");
exit(1);
}
void preamble(list argv, list envp)
{
int
index;
cwd = chdir("."); // get cwd
for (index = 0; home = element(index, envp); index += 2)
{
if (home == "HOME") // HOME found
{ // get it
home = element(index + 1, envp);
break; // and done
}
}
if (!home)
kill("$HOME not found");
progname = change_ext(element(0, argv), "");
attic = home + "/attic"; // set $HOME/attic, change to
}
void check_attic()
{
if (!exists(attic)) // attic should exist
{
printf(attic, " does not exist. Create it [y/n] ? ");
if (getch() != "y") // not a "y" ?
kill("ok.");
system("mkdir " + attic); // make the attic subdir
exec("chmod", 700, attic); // private use
} // else attic must be dir
else if (!((int)element(0, stat(attic)) & S_IFDIR))
kill("'" + attic + "' is not a directory");
attic += "/attic"; // append the zip-name
chdir("/"); // go to the root
}
void set_flags(string arg)
{
int
index;
string
flag;
// process all arguments
for (index = 1; flag = element(index, arg); index++)
{
if (flag == "r") // process encountered options
recurs = "-r";
if (flag == "d")
debug++;
else if (flag == "f")
forced = "-f";
else if (flag == "x")
extract++;
else if (flag == "v")
{
extract++;
viewmode++;
unzipflag = "-l ";
}
else
kill("Unrecognized flag '-" +
flag +
"': " +
progname +
"aborted");
}
if (extract && unzipflag == "")
unzipflag = "-u "; // use proper unzip flag
}
list options(int argc, list argv)
{
int
index;
list
ret;
string
arg;
for (index = 0; index < argc; index++)
{
arg = element(index, argv); // get next argument
if (element(0, arg) == "-") // first element is a - ?
set_flags(arg); // then set flags
else
ret += (list)arg; // or add to list to return
}
return (ret); // returned list
}
void usage()
{
printf
(
"\n"
"ICCE AM (Attic Move) non-destructive remove. Version "
VERSION "\n"
"Copyright (c) ICCE " YEAR ". All Rights Reserved\n"
"\n"
"AM by Frank B. Brokken\n"
"\n"
"Usage: ", progname, " [options] file(s)\n"
"Where:\n"
" options:\n"
" -d: Debug mode: no execution but display of commands\n"
" -f: Forced processing of indicated files\n"
" -r: Recursive removal of directory contents\n"
" -v: View current contents of the attic\n"
" -x: Extract files from the attic to their original place\n"
" (i.e., if you are permitted to do so...\n"
"\n"
" file(s): names of files and directories to move to/from
the attic\n"
"\n"
" ", home, "/attic/attic.zip is used to store the files.\n"
"\n"
);
exit (1);
}
string prefix_path(string file)
{
string
el,
ret;
int
index;
if (element(0, file) != "/") // if file isn't an absolute path
file = cwd + file; // then make an absolute path
for (index = 1; el = element(index, file); index++)
ret += el; // remove first char from abs path
return (ret); // return modified string
}
void retrieve(string file)
{
string
cmd;
cmd = "unzip " // update only
+ unzipflag
+ attic;
if (!viewmode)
cmd += " "
+ prefix_path(file); // and the file (+ path prefix)
if (debug)
printf("( cd /; ", cmd, " )\n"); // debug: show command
else
system(cmd); // else exec cmd
}
void remove(string file)
{
string
cmd;
cmd = "zip -my " // remove, remove links as links
+ forced // maybe forced
+ " "
+ recurs // maybe recursive
+ " "
+ attic // target zip
+ " "
+ prefix_path(file); // and the file (+ path prefix)
if (debug)
printf("( cd /; ", cmd, " )\n"); // debug: show command
else
system(cmd); // else exec cmd
}
void one_file(string file)
{
if (extract) // either retrieve or remove
retrieve(file); // the file
else
remove(file);
}
void process(int argc, list argv)
{
int
index;
for (index = 1; index < argc; index++)
one_file(element(index, argv)); // process one file
}
int main(int argc, list argv, list envp)
{
echo (OFF);
preamble(argv, envp); // set progname and attic dir.
argv = options(argc, argv); // get the options
argc = sizeof(argv); // determine remaining arguments
if (argc == 1 && !viewmode) // none left and no viewmode?
usage(); // give usage and exit 1
check_attic(); // check accessability of attic
if (viewmode) // view contents
retrieve("");
else // or
process(argc, argv); // process remaining arguments
return (0); // done
}
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




5 hours 37 min ago
11 hours 23 min ago
11 hours 40 min ago
13 hours 33 min ago
15 hours 26 min ago
22 hours 21 min ago
22 hours 37 min ago
1 day 28 min ago
1 day 6 hours ago
1 day 10 hours ago