# Scripting and Programming Fundamentals

**URL:** <https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558>\
**Category:** IT and Cybersecurity Foundations\
**Tags:** learning\
**Created:** [February 23, 2024, 1:14pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558 "2024-02-23T13:14:03Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![StrictCatshark0429](https://forums.cybrary.it/user_avatar/forums.cybrary.it/strictcatshark0429/32/11_2.png) [@StrictCatshark0429](https://forums.cybrary.it/u/StrictCatshark0429)\
**Post date:** [February 23, 2024, 1:14pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/1 "2024-02-23T13:14:03Z")

</div>

(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’

---

<div class="post-metadata">

**Author:** ![JosephWhite](https://forums.cybrary.it/user_avatar/forums.cybrary.it/josephwhite/32/2407_2.png) [@JosephWhite](https://forums.cybrary.it/u/JosephWhite)\
**Post date:** [February 23, 2024, 2:13pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/2 "2024-02-23T14:13:14Z")

</div>

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” ?

---

<div class="post-metadata">

**Author:** ![StrictCatshark0429](https://forums.cybrary.it/user_avatar/forums.cybrary.it/strictcatshark0429/32/11_2.png) [@StrictCatshark0429](https://forums.cybrary.it/u/StrictCatshark0429)\
**Post date:** [February 23, 2024, 2:37pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/3 "2024-02-23T14:37:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JosephWhite](https://forums.cybrary.it/user_avatar/forums.cybrary.it/josephwhite/32/2407_2.png) [@JosephWhite](https://forums.cybrary.it/u/JosephWhite)\
**Post date:** [February 23, 2024, 3:11pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/4 "2024-02-23T15:11:21Z")

</div>

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

For BASH, what regex means “starts with”?

---

<div class="post-metadata">

**Author:** ![StrictCatshark0429](https://forums.cybrary.it/user_avatar/forums.cybrary.it/strictcatshark0429/32/11_2.png) [@StrictCatshark0429](https://forums.cybrary.it/u/StrictCatshark0429)\
**Post date:** [February 23, 2024, 3:17pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/5 "2024-02-23T15:17:51Z")

</div>

Thanks alot. I made it 🙂

---

<div class="post-metadata">

**Author:** ![JosephWhite](https://forums.cybrary.it/user_avatar/forums.cybrary.it/josephwhite/32/2407_2.png) [@JosephWhite](https://forums.cybrary.it/u/JosephWhite)\
**Post date:** [February 23, 2024, 3:36pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/6 "2024-02-23T15:36:47Z")

</div>

![image](https://forums.cybrary.it/uploads/default/original/2X/6/690d3babc0ed9c236dfecb13d5ca928fdbba7e6b.png)

---

<div class="post-metadata">

**Author:** ![DrakoTech](https://forums.cybrary.it/user_avatar/forums.cybrary.it/drakotech/32/11_2.png) [@DrakoTech](https://forums.cybrary.it/u/DrakoTech)\
**Post date:** [October 11, 2024, 6:59pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/7 "2024-10-11T18:59:16Z")

</div>

@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…

 ![IMG_1520.HEIC](https://forums.cybrary.it/uploads/default/original/3X/2/d/2d43ca0edd439f599ddf32d791b83975cc74ca91.jpeg)

---

<div class="post-metadata">

**Author:** ![JosephWhite](https://forums.cybrary.it/user_avatar/forums.cybrary.it/josephwhite/32/2407_2.png) [@JosephWhite](https://forums.cybrary.it/u/JosephWhite)\
**Post date:** [October 12, 2024, 5:17pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/8 "2024-10-12T17:17:30Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![DrakoTech](https://forums.cybrary.it/user_avatar/forums.cybrary.it/drakotech/32/11_2.png) [@DrakoTech](https://forums.cybrary.it/u/DrakoTech)\
**Post date:** [October 13, 2024, 8:52am UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/10 "2024-10-13T08:52:46Z")

</div>

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.

 ![WhatsApp Image 2024-10-12 at 01.23.23](https://forums.cybrary.it/uploads/default/original/3X/a/e/ae1b4b3ee056ba81cbc4dec4cd9582dd56a38b96.jpeg)

---

<div class="post-metadata">

**Author:** ![Bath\_Faucet](https://forums.cybrary.it/user_avatar/forums.cybrary.it/bath_faucet/32/11_2.png) [@Bath\_Faucet](https://forums.cybrary.it/u/Bath_Faucet)\
**Post date:** [January 9, 2025, 6:37pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/11 "2025-01-09T18:37:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JosephWhite](https://forums.cybrary.it/user_avatar/forums.cybrary.it/josephwhite/32/2407_2.png) [@JosephWhite](https://forums.cybrary.it/u/JosephWhite)\
**Post date:** [January 9, 2025, 6:52pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/12 "2025-01-09T18:52:58Z")

</div>

The question asks:

![image](https://forums.cybrary.it/uploads/default/original/3X/0/0/00ee20718b94b75f582afb2eba19948df735df48.png)

So what function was **def** ined 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 🙂

---

<div class="post-metadata">

**Author:** ![Bath\_Faucet](https://forums.cybrary.it/user_avatar/forums.cybrary.it/bath_faucet/32/11_2.png) [@Bath\_Faucet](https://forums.cybrary.it/u/Bath_Faucet)\
**Post date:** [January 9, 2025, 6:59pm UTC](https://forums.cybrary.it/t/scripting-and-programming-fundamentals/65558/13 "2025-01-09T18:59:38Z")

</div>

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