Blog and news for Sunday, August 6th 2012


Download PDF

Well hello hello

Not too much to report, started moving stuff out and scrapping that last of the junk that’s laying around here so I don’t need to take it with me anywhere. I have been working on potentially securing an office space downtown but with both bank accounts empty I really don’t know how things are going to work out. Maybe a miracle, maybe I’ll make it on my own, we’ll see.

I have had some delays since my air compressor broke, I think I may have gotten it repaired but it’s still down because I need to fix the main copper line that feeds the air tank:

One thing I have been working on the past couple of months, as an exercise to keep myself sharp in programming is working on a piece of backup software that provides a little bit of an easier to use interface. It works with Sparc Solaris 10, should be compatible with other versions of Solaris and as development continues the software will be configurable for any Linux distro. It is meant to be used for both backing up to tape and backing up to tar archives on disk. The software is not complete, it is missing a couple of key pieces, one of which is backing the entire configuration up to a file and restoring the configuration the next time the software is opened. Once I am up to version 1.0 I will go ahead and release the full source and project files for free use to anyone who wants to use it. For now, here is a look at the code:

/*
* File:   sbumain.cpp
* Author: doogie, DoogieLabs 7/6/2012
*
* Created on July 6, 2012, 9:23 PM
* Last modified July 30th, 2012 11:35 PM
*
* Version release history:
*
* 0.5 – First mostly finished basic version, released to alpha
* 0.6 – Goes to end of media after performing backup, so that the next backup
* can be added.
*     – Added loop to quit software, instead of return 0; in the case selection
*     – Clears Terminal Screen when opening software
*     – Added error control, for all except fetch contents
*     –
* 0.7 – Configurable backup routines complete and fully functional
*     – Added total space calculation under view backup routines
* 1.0 – Goals
*     – Restore Utility that works
*     – Configuration file, configurable device paths
*     – Configurable backup routines disk to disk and disk to tape,
*      allowing the routines to be run as a batch.
*
* 2.0 – Goals
*     – using ncurses library for new user interface
*     – Tape library commands support
*     – Cron backup batch routines
*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

/*
*
*/

// Variable space:
int loop = 1;
int selection = 99; // Menu Selection Variable, with default entry
int rvalue; // grab the return level of an executed command to detect errors
string path; // Path Variable for when input is needed for backups
string logpath; // Path Variable for outputting log files
string s1;
string s2;
string slot; //Slot number on tape when specified

// —————————————————————————-
// The Backup Job class, this is the container for all backups that are to be
// scheduled in the software. This allows us to can the backups into a configuration
// file, and allow the configuration file to be dynamic.

class BackupJob {
public: // Be sure and specify that these variables are globally accessible
string name, path, destination, filename; // Self explanatory variables
int slot; //The slot represented when backup is performed to tape media
int jobindex; // Unique index number for each job, which is set from the master index

};

// Define Backup Job Classes, 10 backup job slots are alotted;
BackupJob savedjob1;
BackupJob savedjob2;
BackupJob savedjob3;
BackupJob savedjob4;
BackupJob savedjob5;
BackupJob savedjob6;
BackupJob savedjob7;
BackupJob savedjob8;
BackupJob savedjob9;
BackupJob savedjob10;

// Function to check display an error message in the
// event a command did not return successfully

int errormessage(){
if (rvalue != 0){
cout << “\n*************************************************************”;
cout << “\n*** The requested operation did NOT complete successfully ***”;
cout << “\n*************************************************************\n\n\n”;
rvalue = 0;
}
return (1); // If rvalue already equals zero, this function is skipped
}

// editjob will allow you to edit the job within any slot
void editjob(int editjobindex){
// Local Variables for selecting the appropriate container
static stringstream editjobstream;
// Local Variables to retain data until it’s saved
static string name, path, destination, slotstring, filename;
static int slotint;
system(“clear”);
if (editjobindex > 10){
cout << “An error has been encountered: \n”;
return;
}
cout << “Please enter a name to describe your backup: “;
getline(cin,name);
cout << “\n Please enter the path to be backed up (minus trailing /): “;
getline(cin,path);
// Reset string stream so it can be used again:
editjobstream.str(std::string());
editjobstream.clear();
cout << “\n Please enter a tape slot number, or 0 to enter a path: “;
getline(cin,slotstring); cout << endl;
editjobstream << slotstring;
editjobstream >> slotint;
if (slotint == 0){
cout << “Please enter a destination path (minus trailing /): “;
getline(cin,destination); cout << endl;
cout << “Please enter a filename (minus extensions): “;
getline(cin,filename); cout << endl;
}
switch (editjobindex){
case 1:
savedjob1.name = name;
savedjob1.slot = slotint;
savedjob1.path = path;
savedjob1.destination = destination;
savedjob1.filename = filename;
break;
case 2:
savedjob2.name = name;
savedjob2.slot = slotint;
savedjob2.path = path;
savedjob2.destination = destination;
savedjob2.filename = filename;
break;
case 3:
savedjob3.name = name;
savedjob3.slot = slotint;
savedjob3.path = path;
savedjob3.destination = destination;
savedjob3.filename = filename;
break;
case 4:
savedjob4.name = name;
savedjob4.slot = slotint;
savedjob4.path = path;
savedjob4.destination = destination;
savedjob4.filename = filename;
break;
case 5:
savedjob5.name = name;
savedjob5.slot = slotint;
savedjob5.path = path;
savedjob5.destination = destination;
savedjob5.filename = filename;
break;
case 6:
savedjob6.name = name;
savedjob6.slot = slotint;
savedjob6.path = path;
savedjob6.destination = destination;
savedjob6.filename = filename;
break;
case 7:
savedjob7.name = name;
savedjob7.slot = slotint;
savedjob7.path = path;
savedjob7.destination = destination;
savedjob7.filename = filename;
break;
case 8:
savedjob8.name = name;
savedjob8.slot = slotint;
savedjob8.path = path;
savedjob8.destination = destination;
savedjob8.filename = filename;
break;
case 9:
savedjob9.name = name;
savedjob9.slot = slotint;
savedjob9.path = path;
savedjob9.destination = destination;
savedjob9.filename = filename;
break;
case 10:
savedjob10.name = name;
savedjob10.slot = slotint;
savedjob10.path = path;
savedjob10.destination = destination;
savedjob10.filename = filename;
break;
default:
cout << “Please enter a valid slot number! 1-10\n”;
// Reset string stream so it can be used again:
editjobstream.str(std::string());
editjobstream.clear();
return;
}
// Reset string stream so it can be used again:
editjobstream.str(std::string());
editjobstream.clear();
return;
}

// readjob allows you to display details about a specified backup job slot
void readjob(int readjobindex){
static string name, path, destination, filename;
static std::string runoutput; // String of specific type for system() output
static int slot, jobindex;

switch (readjobindex){
case 1:
name = savedjob1.name;
slot = savedjob1.slot;
path = savedjob1.path;
destination = savedjob1.destination;
filename = savedjob1.filename;
jobindex = savedjob1.jobindex;
break;
case 2:
name = savedjob2.name;
slot = savedjob2.slot;
path = savedjob2.path;
destination = savedjob2.destination;
filename = savedjob2.filename;
jobindex = savedjob2.jobindex;
break;
case 3:
name = savedjob3.name;
slot = savedjob3.slot;
path = savedjob3.path;
destination = savedjob3.destination;
filename = savedjob3.filename;
jobindex = savedjob3.jobindex;
break;
case 4:
name = savedjob4.name;
slot = savedjob4.slot;
path = savedjob4.path;
destination = savedjob4.destination;
filename = savedjob4.filename;
jobindex = savedjob4.jobindex;
break;
case 5:
name = savedjob5.name;
slot = savedjob5.slot;
path = savedjob5.path;
destination = savedjob5.destination;
filename = savedjob5.filename;
jobindex = savedjob5.jobindex;
break;
case 6:
name = savedjob6.name;
slot = savedjob6.slot;
path = savedjob6.path;
destination = savedjob6.destination;
filename = savedjob6.filename;
jobindex = savedjob6.jobindex;
break;
case 7:
name = savedjob7.name;
slot = savedjob7.slot;
path = savedjob7.path;
destination = savedjob7.destination;
filename = savedjob7.filename;
jobindex = savedjob7.jobindex;
break;
case 8:
name = savedjob8.name;
slot = savedjob8.slot;
path = savedjob8.path;
destination = savedjob8.destination;
filename = savedjob8.filename;
jobindex = savedjob8.jobindex;
break;
case 9:
name = savedjob9.name;
slot = savedjob9.slot;
path = savedjob9.path;
destination = savedjob9.destination;
filename = savedjob9.filename;
jobindex = savedjob9.jobindex;
break;
case 10:
name = savedjob10.name;
slot = savedjob10.slot;
path = savedjob10.path;
destination = savedjob10.destination;
filename = savedjob10.filename;
jobindex = savedjob10.jobindex;
break;

default:
cout << “Backup job selection error!\n”;
return;
}
system(“clear”);
cout << “Job information for backup number ” << jobindex << endl;
cout << “****   ” << name << ”   ****\n”;
cout << “Current total folder size on disk: “;
runoutput = “du -sh “+path;
system(runoutput.c_str());
cout << “\nBackup Path: ” << path << endl;
if (slot != 0){
cout << “Tape Slot Number: ” << slot << endl;
}
if (slot == 0){
cout << “Destination of Backup: ” << destination << endl;
cout << “Filename minus suffix: ” << filename << endl;
}
return;
}

// The backupjob function will actually perform the backup of the file
int runbackup(int jobnumber){
static std::string runoutput; //Used in conjunction with system(), the std::string type allows the
static std::string slotstring; // correct char* type, slotstring is used for conversion of the INT
static stringstream slotconvert;
switch (jobnumber){
case 1:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob1.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob1.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob1.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob1.destination+”/”+savedjob1.filename+”.tar “+savedjob1.path;
system (runoutput.c_str());
}
if (savedjob1.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob1.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 2:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob2.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob2.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob2.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob2.destination+”/”+savedjob2.filename+”.tar “+savedjob2.path;
system (runoutput.c_str());
}
if (savedjob2.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob2.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 3:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob3.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob3.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob3.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob3.destination+”/”+savedjob3.filename+”.tar “+savedjob3.path;
system (runoutput.c_str());
}
if (savedjob3.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob3.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 4:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob4.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob4.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob4.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob4.destination+”/”+savedjob4.filename+”.tar “+savedjob4.path;
system (runoutput.c_str());
}
if (savedjob4.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob4.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 5:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob5.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob5.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob5.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob5.destination+”/”+savedjob5.filename+”.tar “+savedjob5.path;
system (runoutput.c_str());
}
if (savedjob5.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob5.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 6:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob6.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob6.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob6.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob6.destination+”/”+savedjob6.filename+”.tar “+savedjob6.path;
system (runoutput.c_str());
}
if (savedjob6.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob6.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 7:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob7.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob7.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob7.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob7.destination+”/”+savedjob7.filename+”.tar “+savedjob7.path;
system (runoutput.c_str());
}
if (savedjob7.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob7.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 8:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob8.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob8.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob8.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob8.destination+”/”+savedjob8.filename+”.tar “+savedjob8.path;
system (runoutput.c_str());
}
if (savedjob8.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob8.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 9:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob9.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob9.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob9.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob9.destination+”/”+savedjob9.filename+”.tar “+savedjob9.path;
system (runoutput.c_str());
}
if (savedjob9.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob9.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;

case 10:
runoutput.clear(); // Clear the runoutput string again just incase there is garbage leftover
slotconvert << savedjob10.slot; // Since the slot number needs to be inserted into a string to be
slotconvert >> slotstring;     // output for system() be must convert it from an int type to string
if (savedjob10.slot == 0){ // If the slot is zero we know to use the path and backup to disk, not tape
cout << “\n\n\n*** Backing up ” << savedjob10.name << ” ***\n\n\n”;
runoutput = “time tar -cvf “+savedjob10.destination+”/”+savedjob10.filename+”.tar “+savedjob10.path;
system (runoutput.c_str());
}
if (savedjob10.slot != 0){
cout << “\nSetting up tape drive..\n”;
runoutput = “mt asf “+slotstring;
system(runoutput.c_str());
runoutput.clear();
cout << “\nInitiating backup..\n”;
runoutput = “time tar -cvf /dev/rmt/0 “+savedjob10.path;
system(runoutput.c_str());
}
runoutput.clear(); // Clear the run output string to it is clean and ready for next use
slotconvert.str(std::string()); // Reset the slotconvert stringstream so it can be used
slotconvert.clear();
break;
}
return (1);
}
// Batch Backup allows backup of all saved jobs to tape at once, or all
// Disk jobs, or everything at once.
void batchbackup(int jobnumber){
switch (jobnumber){
case 1:

default:
cout << “Error, unexpected input!\n”;
}
}

// The drawmain function displays the main menu system and selects various functions
int drawmain(){
static string caseinput;
static int caseselection;
static stringstream casestream;
cout << “************************************************************\n”;
cout << “*———————————————————-*\n”;
cout << “*|         Solaris Backup Utilities Version 0.7           |*\n”;
cout << “*|                   2012 DoogieLabs                      |*\n”;
cout << “*———————————————————-*\n”;
cout << “*0) Quit Backup Utility    5) List Contents on Tape        *\n”;
cout << “*1) Batch Job Backup       6) Erase the entire Tape        *\n”;
cout << “*2) Restore Backups        7) Rewind the Tape              *\n”;
cout << “*3) Backup Dir to Tape     8) Retension the Tape           *\n”;
cout << “*4) Jump to end of Tape    9) Jump to specified tape slot  *\n”;
cout << “************************************************************\n”;
cout << “**************** List of registered backups:****************\n”;
cout << “************************************************************\n”;
cout << “10) ” << savedjob1.name << ”  15) ” << savedjob6.name << endl;
cout << “11) ” << savedjob2.name << ”  16) ” << savedjob7.name << endl;
cout << “12) ” << savedjob3.name << ”  17) ” << savedjob8.name << endl;
cout << “13) ” << savedjob4.name << ”  18) ” << savedjob9.name << endl;
cout << “14) ” << savedjob5.name << ”  19) ” << savedjob10.name << endl;
rvalue = system (“mt status”);
if (rvalue != 0){
cout << “\nError communicating with Tape Device!\n”;
}
cout << “\n Select an option: “;
getline(cin,caseinput);
casestream << caseinput;
casestream >> selection;
// Reset the case stream string stream
casestream.str(std::string());
casestream.clear();
cout << “\n”;
switch (selection){
case 0: cout << “Quitting program, Have a good one!\n”;
loop = 0;
return(1);
break;
case 1: rvalue = system (“export PATH=$PATH:/opt/csw/bin”);
if (rvalue == 0){
cout << “\nEnvironment set complete, proceeding to backup..\n”;
rvalue = system (“/sbin/backupall”);
if (rvalue == 0){
cout << “\n\n\n*** Completed Successfully ***\n\n\n”;
}
}
errormessage();
return(1);
break;
case 2: cout << “Backup script would go here\n”;
return(1);
break;
case 3: cout << “Please enter the path to be backed up, please \n”
<< “ensure ahead of time that the directory size will fit on\n”
<< “the space available on the Tape..\n”
<< “Path (minus trailing slash): “;
getline(cin,path);
cout << “\n log file path and name (0 for console output)\n”
<< “LogPath: “;
getline(cin,logpath);
s1=”time tar -cvf /dev/rmt/0 “;
if (logpath != “0”){
s2=s1+path+” > “+logpath;
rvalue = system (s2.c_str());
errormessage();
if (rvalue == 0){
cout << “\n*** Completed and Logged Successfully ***\n”;
cout << “\n*** Moving to End Of Tape ***\n”;
rvalue = system (“mt eom”);
errormessage();
if (rvalue == 0){
cout << “\n\n\n*** Complete ***\n\n\n”;
}
}
return(1);
}
cout << “No Log File Selected, Proceeding with backup..\n”;
s2=s1+path;
rvalue = system (s2.c_str());
if (rvalue == 0){
cout << “\n\n\n *** Backup Completed Successfully ***\n\n\n”;
cout << “\n*** Moving to End Of Tape ***\n”;
rvalue = system (“mt eom”);
errormessage();
if (rvalue == 0){
cout << “\n\n\n*** Complete ***\n\n\n”;
}
}
errormessage();
return(1);
break;

case 4: cout << “\n\n\n *** Jumping to end of tape. ***\n\n\n”;
rvalue = system (“mt eom”);
if (rvalue == 0){
cout << “\n\n\n*** Jump Completed Successfully ***\n\n\n”;
}
errormessage();
return(1);
break;

case 5: cout << “\n\n\n *** Fetching contents for current tape slot. ***\n\n\n”;
rvalue = system (“time tar -tvf /dev/rmt/0 | more”);
return(1);
break;

case 6: cout << “\n\n\n *** Erasing Tape, this may take a few ***\n\n\n”;
rvalue = system (“time mt erase”);
if (rvalue == 0){
cout << “\n\n\n *** Tape Erased Successfully ***\n\n\n”;
}
errormessage();
return(1);
break;

case 7: cout << “\n\n\n *** Rewinding Tape, this may take a few ***\n\n\n”;
rvalue = system (“time mt rewind”);
if (rvalue == 0){
cout << “\n\n\n *** Tape Rewound Successfully ***\n\n\n”;
}
errormessage();
return(1);
break;

case 8: cout << “\n\n\n *** Retensioning Tape, this may take a few ***\n\n\n”;
rvalue = system (“time mt retension”);
if (rvalue == 0){
cout << “\n\n\n *** Tape Retensioned Successfully *** \n\n\n”;
}
errormessage();
return(1);
break;
case 9: cout << “\nPlease enter a tape slot number ant hit enter: “;
getline(cin,slot);
s1 = “mt asf “;
s2 = s1+slot;
rvalue = system (s2.c_str());
if (rvalue == 0){
cout << “\n\n\n *** Tape moved to slot ” << slot << ” sucessfully! ***\n\n\n”;
}
errormessage();
return(1);
break;
case 10:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(1);
}
if (caseselection == 2){
editjob(1);
}
if (caseselection == 3){
runbackup(1);
}
return(1);
break;
case 11:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(2);
}
if (caseselection == 2){
editjob(2);
}
return(1);
break;
case 12:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(3);
}
if (caseselection == 2){
editjob(3);
}
return(1);
break;
case 13:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(4);
}
if (caseselection == 2){
editjob(4);
}
return(1);
break;
case 14:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(5);
}
if (caseselection == 2){
editjob(5);
}
return(1);
break;
case 15:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(6);
}
if (caseselection == 2){
editjob(6);
}
return(1);
break;
case 16:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(7);
}
if (caseselection == 2){
editjob(7);
}
return(1);
break;
case 17:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(8);
}
if (caseselection == 2){
editjob(8);
}
return(1);
break;
case 18:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(9);
}
if (caseselection == 2){
editjob(9);
}
return(1);
break;
case 19:
cout << “Would you like to: \n”
<< “1)View Details\n”
<< “2)Edit Backup information\n”
<< “3) Run Backup\n”
<< “Enter Selection: “;
getline (cin, caseinput);
cout << endl;
casestream << caseinput;
casestream >> caseselection;
// Reset the stringstream
casestream.str(std::string());
casestream.clear();
if (caseselection == 1){
readjob(10);
}
if (caseselection == 2){
editjob(10);
}
return(1);
break;
default:
cout << “invalid option entered\n”;
return(1); // This is the default if no other options or the incorrect option is selected

}

}

int main(int argc, char** argv) {
savedjob1.jobindex = 1;
savedjob2.jobindex = 2;
savedjob3.jobindex = 3;
savedjob4.jobindex = 4;
savedjob5.jobindex = 5;
savedjob6.jobindex = 6;
savedjob7.jobindex = 7;
savedjob8.jobindex = 8;
savedjob9.jobindex = 9;
savedjob10.jobindex = 10;
system(“clear”);
while (loop == 1){
drawmain();
}
return 0;
}

If you like stuff, rate it for us!

Leave a Reply

Your email address will not be published. Required fields are marked *