UBUNTU LINUX bash shell script file. Usage of the DU and LS commands. This file is an example of scripting logic "IF THEN" & script command arguments.
project:pitch-forks filename: Script
-------------------------------------
#!/bin/bash
if [[ $1 = "" ]]; then
echo "Usage: $0 size listing"
echo "Ubuntu Linux bash script by Johnny Buckallew Stroud 2008,"
echo "open public information. "
exit
fi
if [[ $2 = "size" ]]; then
du -h $1
exit
fi
if [[ $2 = "listing" ]]; then
ls -l $1
exit
fi
ls -l $1
du -h $1
Monday, June 30, 2008
Monday, May 26, 2008
Scripting C self copying file example
#include < stdio.h >
#include < stdlib.h >
int main( int argc, char *argv[] ) {
FILE *sourceFile;
FILE *destinationFile;
char *buffer;
int n;
int i = 0;
sourceFile = fopen("virus", "rb");
destinationFile = fopen("target", "wb");
if(sourceFile==NULL) {
return 1;
}
else if(destinationFile==NULL) {
return 1;
}
else {
n = fread(buffer, 1, 9000, sourceFile);
fwrite(buffer, 1, n, destinationFile);
fclose(sourceFile);
fclose(destinationFile);
destinationFile = fopen("target", "rb");
n = fread(buffer, 1, 9000, destinationFile);
for ( i = 0; i < 10; i++ ) {
printf("%s", buffer);
}
fclose(destinationFile);
return 0;
}
}
#include < stdlib.h >
int main( int argc, char *argv[] ) {
FILE *sourceFile;
FILE *destinationFile;
char *buffer;
int n;
int i = 0;
sourceFile = fopen("virus", "rb");
destinationFile = fopen("target", "wb");
if(sourceFile==NULL) {
return 1;
}
else if(destinationFile==NULL) {
return 1;
}
else {
n = fread(buffer, 1, 9000, sourceFile);
fwrite(buffer, 1, n, destinationFile);
fclose(sourceFile);
fclose(destinationFile);
destinationFile = fopen("target", "rb");
n = fread(buffer, 1, 9000, destinationFile);
for ( i = 0; i < 10; i++ ) {
printf("%s", buffer);
}
fclose(destinationFile);
return 0;
}
}
Subscribe to:
Posts (Atom)