On Aug 27, 8:34 am, Juan Miguel Paredes <[email protected]>
wrote:
> On Thu, Aug 27, 2009 at 8:14 PM, Dos-Man 64<[email protected]> wrote:
>
> > Oh, God! My machine is slow, it can barely even run DSL-embedded that
> > way. Another reason I was using 98 :)
>
> > I am going to ditch 98 soon. I'm just keeping around because I
> > occasionally run into tasks that I don't know how to do in linux.
> > Anyway, I ordered some software a while ago, and I want to test it
> > out. As a programmer, I should be able to make good things happen
> > even with a live distro. I tend to be more focused on writing my own
> > software than on anything anybody else has created. If I can't create
> > any useful software with a live distro, then I most likely couldn't
> > create anything useful with a full distro either.
>
> > And I still haven't made up my mind what distro I should use when I do
> > switch over.
>
> Dos-Man,
>
> Just so you know... "wcd" also runs on DOS.
>
> Cheers,
>
> Juan
Well, I'm sure it is very interesting but I am really trying to get
away from DOS.
At any rate, I did some more work on my utility and it is now working
great. You can try it out and let me know what you think of it.
I will first list the source here for the bash script (gscript). This
must be launched with
. gscript
----------------------------------------------------------
# start of gscript
#!/bin/sh
# You must execute this script using the following syntax: . gscript
PATHBACK=$PATH
PATH=$(pwd):$PATH
RESULT=1
while [ -n "$RESULT" ]
do
r=$(pwd)
dialog --ok-label Change --cancel-label Close --no-shadow --
backtitle guicd --title $(pwd) --menu "Choose a folder." 20 45 14 $(/
ramdisk/home/knoppix/Desktop/guicd) 2> /ramdisk/home/knoppix/Desktop/
guicd.tmp
RESULT=$(cat /ramdisk/home/knoppix/Desktop/guicd.tmp)
cd $(/ramdisk/home/knoppix/Desktop/newfolders /ramdisk/home/
knoppix/Desktop/guicd.tmp) > /dev/null
done
PATH=$PATHBACK
cd $r
# end of gscript
---------------------------------------------------------------------------------------------
Note the hard-coded knoppix-related paths. You have to change these
according to your setup. All 3 files must be located in same
directory. And you must change to this folder before you run
gscript. When I switch to a full linux version I will have more
control over the startup files and whatnot, so this will eventually
change.
Now here are the 2 C programs, guicd.c and newfolders.c
Compile to executables with gcc
gcc -o guicd guicd.c
gcc -o newfolders newfolders.c
---------------------------------------------------------------------------------
// start of guicd.c
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
void newstrcat(char * dest, char * source);
void printdir(char * dir);
void inttostr(char * x);
char curdir[266] = "";
char cmdline[32000] = "";
int counter = 0;
int main()
{
int result;
getcwd(curdir, 265);
printdir(curdir);
printf("%s", cmdline);
}
void printdir(char * dir)
{
DIR * dp;
char num[20] = "";
char twobytes[2]="";
struct dirent * entry;
struct stat statbuf;
if((dp=opendir(dir)) == NULL)
{
fprintf(stderr, "Failed.\n");
return;
}
while((entry=readdir(dp))!= NULL)
{
lstat(entry->d_name, &statbuf);
if(S_ISDIR(statbuf.st_mode))
{
counter++;
newstrcat(cmdline," ");
sprintf(num, "%i ", counter);
newstrcat(cmdline,num);
strcpy(num,"");
newstrcat(cmdline, entry->d_name);
}
}
closedir(dp);
} // end of printdir()
void newstrcat(char * dest, char * source)
{
if ((strlen(dest) + strlen(source)) >= 32000)
{
fprintf(stderr, "Failed.\n");
exit(0);
}
else
{
strcat(dest,source);
}
}
// end of guicd.c
----------------------------------------------------------------------
-----------------------------------------------------------------------
// start of newfolders.c
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <ctype.h>
#include <stdlib.h>
void printdir(char * dir, int whichdir);
char curdir[266] = "";
char cmdline[32000] = "";
int counter = 0;
char buffer[4]="";
char new[4] = "";
int intbuff;
int main(int args, char * argv[])
{
FILE * openit;
int result;
getcwd(curdir, 265);
openit = fopen(argv[1],"r");
if(feof(openit))
{
printf("./");
return 0;
}
fscanf(openit,"%i", &intbuff);
fclose(openit);
if(strlen(curdir)==1)
{
printdir(curdir, intbuff);
return(0);
}
else
{
if (intbuff==1)
{
printf("./");
return(0);
}
if (intbuff==2)
{
printf("../");
return(0);
}
printdir(curdir, intbuff);
return(0);
}
} // end of main()
void printdir(char * dir, int whichdir)
{
DIR * dp;
struct dirent * entry;
struct stat statbuf;
if((dp=opendir(dir)) == NULL)
{
fprintf(stderr, "Failed.\n");
return;
}
while((entry=readdir(dp))!= NULL)
{
lstat(entry->d_name, &statbuf);
if(S_ISDIR(statbuf.st_mode))
{
counter++;
if (counter==whichdir)
{
printf("./%s", entry->d_name);
closedir(dp);
exit(0);
}
}
}
closedir(dp);
} // end of printdir()
// end of newfolders.c
----------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at
http://groups.google.com/group/linuxusersgroup
-~----------~----~----~----~------~----~------~--~---