mikeizbicki / ucr-cs100 Goto Github PK
View Code? Open in Web Editor NEWopen source software construction course
License: Other
open source software construction course
License: Other
Im working on my code and i'm stuck in here:
129 while ((direntp = readdir(dirp)))
130 {
131 if (s.st_mode & S_IRUSR){
132 cout << 'r';
133 } else{
134 cout << '-';
135 }
136 if (s.st_mode & S_IWUSR){
137 cout << 'w';
138 } else{
139 cout << '-';
140 }
141 if (s.st_mode & S_IXUSR){
142 cout << 'x';
143 } else{
144 cout << '-';
145 }
146 files.push_back(direntp->d_name);
147 }
how can i output the individual files information? I removed the other information output, but when i call it, it all outputs it for just the current directory information. How can i make it output the individual files information. I pushed all the file/directory names into a string of vectors incase i could use it for the actual process. Any help will be appreciated!
Hi guys,
Im redoing my user input into the array since we last learned how to completely use the malloc/new but in office hours, i don't remember what the sizeof(char_) refers to:
int x= how many params;
c = malloc(x * sizeof(char_));
and for the individual array indexs' we just allocate memory for the size of the word being put in there as well, correct?
Thank you.
So I'm having some weird problems calling ls on directories.
My code works when I call: ./a.out bin -l (or any other flags/combinations of flags)
But when I JUST call: ./a.out bin, I get the correct output, but with a few added error messages:
Here is my output when I call ./a.out bin
Error with stat: No such file or directory
Error with readdir: No such file or directory
Error with readdir: No such file or directory
rshell
Here is the correct output (ls bin)
rshell
So as you can see, mine outputs rshell in the end, but has three error messages that comes with it. And when I append flags, in any combination, any flags, any order, those error messages no longer occur.
i am so confused on what to do inside the makefile, i know its late but ive never made one before and ive looked at tutorials online and not found them very helpful
I'm getting the error: 'bus error: 10' when i run my code. I debugged and stepped through my code and when i reached line 55 in my code, i don't know if my code freezed or not but it looked like an infinite loop. however there's no loop started on that line. I called fork two lines earlier and i was able to step to the next line, so i don't know if that's the problem.
my code: https://github.com/kryne001/rshell/
Hey guys,
I for one like my code to auto indent every line below my first indented line and VIM doesn't do it by default and I've been looking for a solution for a while and finally came across the answer!
type: echo set autoindent >> .vimrc
in a terminal window. This will add to the default list and once you indent the first line, all lines below it will be indented as well.
Enjoy!
I'm going to extend the due date of homework 1 until Thursday before class. Please use the weekend to start on the project so you can be prepared to ask questions on Monday. I'm expecting this first assignment to be high quality.
I'm having a problem freeing my array of char**. i'm able to free the whole array without freeing each index first (which I know is wrong), but if I try to free each index, I get the following error in gdb:
malloc: *** error for object 0x7fff5fbff3a9: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
I've gone through and checked that there was indeed a value there, which there was, and I think I'm allocating the memory for each index correctly, so I don't know where I should look to fix it.
when ls -l is entered, the first line says:
total 24
What part of the stat struct does that total number come from? Is it st_blocks?
I will be hosting office hours Thursday August 14th 10-11am in WCH 110.
I'm trying to do what Mike said in lecture today to test &, trying "cat /dev/random > rand &"
and > doesn't seem to work? It does not create a file called rand but it kind of does run in the background, the random numbers still show in the terminal but it allows me to write in commands.
Is there a reason that output redirection does not work ?
Hey everyone:
When I run my makefile with the make command, I get this error:
g++ -Wall -Werror -ansi src/main.cpp -o ./bin/rshell
/usr/bin/ld: cannot open output file ./bin/rshell: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [rshell] Error 1
g++: error: unrecognized command line option ‘-strict’
This line right here is pretty much the bulk of my makefile:
g++ -Wall -Werror -ansi -strict src/main.cpp -o ./bin/rshell
Any ideas? Thanks!
I forgot to mention in class two more functions that you'll find useful for the assignment. The stat
struct only gives you the userid, not the username. You can use the getpwuid
function to get the username from the uid. Also, the time_t
type is an int
that represents the number of seconds since 1970. You can convert this into a readable time using the strftime
function. This stackoverflow question has a worked example: http://stackoverflow.com/questions/18422384/how-to-print-time-t-in-a-specific-format
Do we have to manually write a function to parse user input or can we use a library function?
I found a function named strtok that I believe I could use for user input
Is this allowed?
When testing, should we test with "./a.out ls -l -a" or "./a.out -l -a".
To word my question a little better, should we test with or without the ls, and when you guys do the final check, are you going to be typing in ls or not? And is this the correct way to test it?
Hey mike when is the last day to turn in hw1 late?
Can someone help me with the -R flag formatting? I have everything working, but I'm having a lot of trouble with formatting.
Instead of printing all the file+directory names first, then recursing into the directories and printing their contents, mine recurses into the directory as soon as it gets to it. I can post my code as well, just need to make sure I'm allowed to post it here first.
Thanks!
For some reason. as soon as I start script, my rshell executable will not execute. It works fine if script is not running... After I start script exec.script, I call ./rshell, and then it just hangs on a blank line.
i'm trying to do the part of the lab where i type the following command:
$ git push origin master
it has me put my username and password for github, then says:
remote: Permission to mikeizbicki/ucr-cs100.git denied to kryne001.
fatal: unable to access 'https://github.com/mikeizbicki/ucr-cs100/': The requested URL returned error: 403
On my grading it says that my homework did not compile again even though I literally can only get it to compile and run on the well server. I was even showing Mike in office hours today how my program runs (albeit improperly) but it still ran. I don't see any possible way it doesn't compile and run.
I am not too sure what time the homework is due. I vaguely remember it being due at 2, but am not too sure and don't know if it would be am or pm. Do any of you remember?
So for assignment 1 I used the function strtok to parse the input and eliminate any spaces. For assignment 3 when we parse input, we should be looking for the following characters: <, >, >>, | correct? Then we have to remove them so we can run the commands on evec right? Can anyone can give me a hint as to what way would be the best way to parse my input? I'm rather stuck on this portion.
Late submissions for HW 1 will be taken under the following conditions:
i) You needed more time to complete the assignment
ii) You did not follow the specifications and one or more of the following doesn't work for you homework:
$ git clone http://github.com/yourusername/rshell.git
$ cd rshell
$ git checkout hw1
$ make
$ bin/rshell
By turning in a late submission you will acknowledge the following conditions:
i) Your grade for HW 1 will have a penalty of 25 points.
ii) Other penalties may occur
ii) Due date is Sunday August 10th @ 12PM.
iii) You will need to Notify me before the deadline that you making a late submission by stating so as a comment to this post. Failure to notify by the deadline with result in the grade standing as it was the first time it was graded.
iv) Late submission is not a reshow
v) Being able to turn in a late submission is a privilege that can be revoked without any question.
since i messed up and did not create a branch for homework 1, can i save my files in a different location, delete the repository and start over to make sure everything is fine?
Hey everybody,
I have two questions:
This statement here is giving me compiler errors:
if(read(fd, "README", 6) == -1)
{
perror("read failed");
exit(1);
}
This is the compiler error I'm getting:
main.cpp:33:28: error: invalid conversion from ‘const void_’ to ‘void_’ [-fpermissive]
if(read(fd, "README", 6) == -1)
^
In file included from main.cpp:5:0:
/usr/include/unistd.h:360:16: error: initializing argument 2 of ‘ssize_t read(int, void*, size_t)’ [-fpermissive]
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur;
Thanks!
So when I clone my repository, it's unable to find the hw2 branch. On my computer, I can checkout to it fine, but it gives me this warning:
warning: refname 'hw2' is ambiguous
switched to branch 'hw2'
how do i fix this and push it back up to git?
I was wondering if anyone could give me a hint on how to pass in files for the assignment?
for example if i want to do "ls a.out"
If the user inputs a folder i can easily do ls commands with it but i'm kind of confused what i should do for files
Hey everyone:
When working at home, I've been getting this problem when trying to run:
git commit -m "added the first code"
This is what I get:
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
However, when I try to run git config followed by my info, I get an error that says invalid key. Any ideas? Thanks!
Anyone know where we can find good answers on what exactly each part of ls -l is/what part of the struct stat it relates to?
when i define my macros like
it wants me to put semicolons at the end but i know you are not supposed to
what do i do to fix this?
is this a mistake? i dont recognize much things in this file
My internet is done at the moment and not sure when it will come back today, so your HW 1 grades will not be up tonight and should be up by the end of Tuesday along with your HW 2 grades.
If anyone would like to come join a few of us at the ACM room right now, feel free to do so.
We have card access so it wouldn't be an issue getting you in.
I got -10 for not being able to take directories as parameters but I just checked and it can take directories as well as files as parameters
How is this being tested for grading?
Also, I got 10 points off for no perror but i'm pretty sure I have a perror for every sys call, I just double checked...
so in assignment 2 we have to take in the commands, for example ls -a, do we need to access each individual file or directory in the directory that we are in and print out each individually? and for -l we need to go in get all neccesary information about the files and print that out correct?
HW 2 will be graded by the end of Wednesday night. Sorry for the delay.
I just saw my grade, which was given because my program did not compile, but I did all five steps shown in the homework,
git clone (myrepo)
cd rshell
git checkout hw1
make
bin/rshell
I've done it at least four times when I cloned four different repos and they worked each time without me doing anything other than those fives commands.
Does anyone have any idea how to do read in user input to execl/execv?
The idea I have so far is to parse the user input, then append it onto /bin if appropriate, and then have it be read into execv, but I'm not too sure how to do this.
Also, does anyone have the files that were used in lecture today? I can't seem to find them.
Thanks!
when you guys are testing the homework you will not be writing git init right? because when i clone the repo and cd into rshell, when i type git checkout hw1 it only works when i type git init. is this ok? i dont know how else to upload it so i do not have to do this
Just to make sure I don't get marked off points for this but, can i have my makefile remove an existing bin folder if there is one in the current directory? I got tired of having to type the command "make clean" everytime I wanted to re-"make" my file. So now whenever I type "make", it always removes any existing bin folder and creates a new one with the newly compiled executables.
do we need to issue a pull request when we update our repo? i know we did this in lab but i wasnt sure if we have to for our homework
I'm trying to get all the info to print out for -l and when I try to output st_nlink I get an error.
I haven't really changed much code from what is given to us from the assignment, this is what i have:
while((direntp = readdir(dirp)))
{
cout<d_name<<endl;
struct stat s;
stat(direntp->d_name,&s);
cout<<"st_nlink: " << s.st_nlink<<endl;
}
Here's what happens when I try to run a.out:
kgall005@well $ ./a.out
.
what is st_nlink : 2
..
what is st_nlink : 9
*** glibc detected *** ./a.out: double free or corruption (top): 0x00000000100ab010 ***
======= Backtrace: =========
/lib64/libc.so.6[0x329027174f]
/lib64/libc.so.6(cfree+0x4b)[0x3290275a4b]
/lib64/libc.so.6(closedir+0xd)[0x32902963dd]
./a.out(__gxx_personality_v0+0x254)[0x400c14]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x329021d9c4]
./a.out(__gxx_personality_v0+0x39)[0x4009f9]
======= Memory map: ========
00400000-00402000 r-xp 00000000 00:1c 20236672 /home/csmajs/kgall005/cs100/ls/a.out
00601000-00602000 rw-p 00001000 00:1c 20236672 /home/csmajs/kgall005/cs100/ls/a.out
100ab000-100cc000 rw-p 100ab000 00:00 0 [heap]
328fe00000-328fe1c000 r-xp 00000000 09:00 41619551 /lib64/ld-2.5.so
329001c000-329001d000 r--p 0001c000 09:00 41619551 /lib64/ld-2.5.so
329001d000-329001e000 rw-p 0001d000 09:00 41619551 /lib64/ld-2.5.so
3290200000-329034f000 r-xp 00000000 09:00 41619552 /lib64/libc-2.5.so
329034f000-329054f000 ---p 0014f000 09:00 41619552 /lib64/libc-2.5.so
329054f000-3290553000 r--p 0014f000 09:00 41619552 /lib64/libc-2.5.so
3290553000-3290554000 rw-p 00153000 09:00 41619552 /lib64/libc-2.5.so
3290554000-3290559000 rw-p 3290554000 00:00 0
3290600000-3290682000 r-xp 00000000 09:00 41619556 /lib64/libm-2.5.so
3290682000-3290881000 ---p 00082000 09:00 41619556 /lib64/libm-2.5.so
3290881000-3290882000 r--p 00081000 09:00 41619556 /lib64/libm-2.5.so
3290882000-3290883000 rw-p 00082000 09:00 41619556 /lib64/libm-2.5.so
3294e00000-3294e0d000 r-xp 00000000 09:00 41619558 /lib64/libgcc_s-4.1.2-20080825.so.1
3294e0d000-329500d000 ---p 0000d000 09:00 41619558 /lib64/libgcc_s-4.1.2-20080825.so.1
329500d000-329500e000 rw-p 0000d000 09:00 41619558 /lib64/libgcc_s-4.1.2-20080825.so.1
3295600000-32956e6000 r-xp 00000000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32956e6000-32958e5000 ---p 000e6000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32958e5000-32958eb000 r--p 000e5000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32958eb000-32958ee000 rw-p 000eb000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32958ee000-3295900000 rw-p 32958ee000 00:00 0
2b77ac472000-2b77ac475000 rw-p 2b77ac472000 00:00 0
2b77ac4a5000-2b77ac4a7000 rw-p 2b77ac4a5000 00:00 0
7fffa4aed000-7fffa4b02000 rw-p 7ffffffe9000 00:00 0 [stack]
7fffa4bfd000-7fffa4c00000 r-xp 7fffa4bfd000 00:00 0 [vdso]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vsyscall]
Aborted
Can someone explain the last part of quiz 3 with the structs or point me to a link that can do so? I have the answers, but especially for the first column (sizeof(s1), sizeof(s2), sizeof(s3), etc) I don't really understand the answers the compiler is giving back. Thanks!
Hi, I just finished vim-adventures and I remember that we were told that you get a certificate or something at the end of the game but it just goes to a black screen.
What am I supposed to show in order to get the extra credit? I did screenshot the final screen
I'm getting a warning from the code given in assignment two from this line of code:
char *dirName = ".";
The warning is: warning:deprecated conversion from string constant to 'char*'
The command line args are supposed to tell us what version of ls we're supposed to do right? So when the program is run it should be something like, "./a.out ls -al" ?
How are we supposed to differentiate between if they were to put -la or -al or any combination of the three possible flags ? I can't think of a way to do it that just isn't checking for each possibility one by one which is way too long.
Can anyone give me some hints?
since we are running bin/rhsell for this assignment, we have to modify the .cpp file from our assignment 1 correct?
I'm trying to make sure I understand all aspects of the assignment so I wanted to clarify some things.
We are creating the ls.cpp separate from our rshell.cpp file but they will be in the same repository, right?
How should we set up user input? Can we make it so when the program runs we take one ls command and then the program quits
Or do we have to do something like we continuously take commands until they exit the program?
I'm getting a readdir error ONLY with the -R flag, and only when it's recursing into a directory/folder. The perror that I'm getting is "No such file or directory". I suspect it's because it's trying to read it some files that start with . that are there, but I'm pretty sure I already check for them. Another thing is it still outputs the correct things, just with a whole bunch of readdir errors. Example below.
correct output for recursion:
./tests:
exec.script
my output:
./tests:
Error with readdir: No such file or directory
Error with readdir: No such file or directory
Error with readdir: No such file or directory
exec.script
Any help would be greatly appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.