Scripting and Programming Fundamentals

(Scripting and Programming Fundamentals) i got the flag in powershell but I could not get the flag in python 17/18 and in bash 20/21

python:
I cant get the last point for testing if the file exists
xx xxxx(‘/home/cybrary/Desktop/movies.txt’,‘r’):

Bash script:
we want to find files in /etc beginning with lowercase x:
xx /etc | xxxx ‘xx’

For Python, there are common ways to test for a file after you import os, but how can you see if a file exists without that? The hint is, can the file be opened for reading?

On BASH you want to LIST files that contain an x at the start. How do we list files? How do we test for matching criteria? How do we see if something BEGINS with “x” ?

1 Like

Joseph, thanks for the hints in python i made it but unfortunately I couldn’t do it :frowning: ls for listing x* for files starts with lower x after | i put grep

For python, how can you tell IF a file will, OPEN?

For BASH, what regex means “starts with”?

Thanks alot. I made it :slight_smile:

1 Like

image

3 Likes

@josephwhite pls i was able to get the flag for bash and powershell but am stuck at python so far i have 13 flags out of 18 attached is my screenshot. i only know of 1 question left to answer and i still have 5 flags to complete this taks pls kindly help me out i have spent over 12hrs alone on this task pls kindly help me out here what am i missing or what do i need to do
Uploading: IMG_1520.HEIC…

You are missing the part where you call the function…you have to use the name of the function.

def greeting(name):
/# Fix so that the greeting works: e.g. “Hello Joe !” or “Hello Sam !”
print(“xxxxxx” + xxxx + “xx”)
return

/# Replace xxxxx with command to accept user input
name = xxxxx("What is your name? : ")
/# Call the correct function
xxxxxxxx(name)

Hello i am stuck with question #27 which say call the correct function for - print (“your number is” + xxxxxxxxxxx(number)) Please how do i fix this. Thanks a lot for your help.

also stuck on the xxxxxxxxxxx(number) one. cant find any answers online or in notes. maybe im blind

The question asks:

image

So what function was defined in the script above, what is its name? You correctly fixed part of that script to convert the string to an integer and by adding the modulo operator :slight_smile:

1 Like

oh joseph… i love you man. your too good at your job.
got the flag! thanks

2 Likes