0

In 18.04 this code worked just fine

#!/bin/bash
# Opens Libreofice most recent version of Weekly Task Sheet using zsh
# Following creating the script, at root terminal command evaluate chmod 755 tasksheet
# to set permissions; then execute with ./tasksheet
# linuxcommand.org/lc3_wss0010.php

zsh -c 'soffice <path>/WeeklyTaskSheet/*.odt(om[1])'

I am not finding where to put it in 22.04. I have no error messages to report as I have yet to find where it belongs. I find a /bin/bash file but when I cat/bin/bash I get machine language, nothing that is welcoming to edit.

@rexypoo It was done a long time ago in 18.04 and the entire incident today is following a computer hardware upgrade with the old box now recycled.

@usr68186 here is a little progress based on suggestions so far. The script is now in a file in what I think is my home folder.

screenshot

Returning to this and following the suggestions, here is what I get

roger@roger-Precision-Tower-3620:~$ ls -l tasksheet
-rw-rw-r-- 1 roger roger 70 Nov  8 19:10 tasksheet
roger@roger-Precision-Tower-3620:~$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  snap  tasksheet  Templates  Videos
roger@roger-Precision-Tower-3620:~$ cat tasksheet
zsh -c 'soffice LS220DB8F0/AWP/WPGenerl/WeeklyTaskSheet/*.odt(om[1])'
roger@roger-Precision-Tower-3620:~$ 

After running chmod, I still am falling short:

roger@roger-Precision-Tower-3620:~$ ls -l tasksheet
-rwxrwxr-x 1 roger roger 70 Nov  8 19:10 tasksheet
roger@roger-Precision-Tower-3620:~$ .tasksheet
.tasksheet: command not found

I found "Open in Terminal" as a way to access the NAS drive and now think the problem is in how I am describing the path to the executable. Here is what I got back when I modified my script

zsh -c 'soffice /run/user/1000/gvfs/smb-share:server=ls220db8f0,share=share$ /AWP/WPGenerl/WeeklyTaskSheet/*.odt(om[1])'
roger@roger-Precision-Tower-3620:/bin$ ./ tasksheet
bash: ./: Is a directory

You are INCREDIBLY patient with me. I sure think I followed your instructions, but am still not there yet

roger@roger-Precision-Tower-3620:~$ mkdir bin
roger@roger-Precision-Tower-3620:~$ ls
bin      Documents  Music     Public  tasksheet  Videos
Desktop  Downloads  Pictures  snap    Templates
roger@roger-Precision-Tower-3620:~$ pwd
/home/roger
roger@roger-Precision-Tower-3620:~$ mv tasksheet /home/roger/bin/tasksheet
roger@roger-Precision-Tower-3620:~$ ls
bin      Documents  Music     Public  Templates
Desktop  Downloads  Pictures  snap    Videos
roger@roger-Precision-Tower-3620:~$ cd bin
roger@roger-Precision-Tower-3620:~/bin$ ls
tasksheet
roger@roger-Precision-Tower-3620:~/bin$ ./tasksheet
zsh:1: no matches found: /AWP/WPGenerl/WeeklyTaskSheet/*.odt(om[1])
roger@roger-Precision-Tower-3620:~/bin$ pwd
/home/roger/bin
roger@roger-Precision-Tower-3620:~/bin$ ls
tasksheet
roger@roger-Precision-Tower-3620:~/bin$ tasksheet
tasksheet: command not found
roger@roger-Precision-Tower-3620:~/bin$ pwd
/home/roger/bin
roger@roger-Precision-Tower-3620:~/bin$ 
7
  • 2
    Does this answer your question? Where should I put my Bash scripts?
    – user68186
    Nov 8, 2022 at 2:53
  • Based on the comments on the script, the file tasksheet should be in the folder /home/username where the username may be rogo.
    – user68186
    Nov 8, 2022 at 2:57
  • Can you clarify what you did on 18.04 that worked? Also "I am not finding where to put it in 22.04" put what exactly? If you save this script in your home directory as "tasksheet" try running it with "bash -X ./tasksheet" and see if that generates helpful errors.
    – rexypoo
    Nov 8, 2022 at 2:59
  • Please don't put screenshots of the terminal in the question. Always copy the text from the terminal (using mouse and right click) and paste it directly in your question. Then format the pasted text as code. Having said that, the screenshot was useful. Run the command ls -l tasksheet and paste the output in your question. My guess is the ownership has changed somehow.
    – user68186
    Nov 9, 2022 at 14:43
  • Putting all the new information in the question is a good practice. But putting "@user68186" in the question does not help me. If you want to get my attention write a comment starting with "@user68186" that in a comment.
    – user68186
    Nov 9, 2022 at 14:45

1 Answer 1

2

Make the script executable

A script is just a plain text file. You have to tell Ubuntu that that the file is executable. There are various way of doing it.

In a Terminal

The command line method is tow type the command:

chmod +x tasksheet

After this command if you run ls -l tasksheet again you will see a x like -rwxr... in the output. The x indicates the file is now executable.

The GUI and Mouse way

Open the app Files (AKA Nautilus) and right click on the file tasksheet inside Files.

Select Properties from the right click context menu. Go to the Permissions tab:

enter image description here

Check the box Allow executing file as program.

You only need to do one or the other, not both. After that, you can use the command:

.tasksheet

See How can I make a script executable? for more.

Additional Guidance

You must have typed cd /bin to get to the prompt:

roger@roger-Precision-Tower-3620:/bin$

If you intended to go to /home/roger/bin/, you should type cd bin. The you will see the prompt:

roger@roger-Precision-Tower-3620:~/bin$

Note the ~ before the /.

Then you have typed:

roger@roger-Precision-Tower-3620:/bin$ ./ tasksheet
# There should be no space here          ↑

Try ./tasksheet. That is:

roger@roger-Precision-Tower-3620:/bin$ ./tasksheet

If you have moved the file tasksheet from /home/roger/ to /bin. This is not recommended. Important system programs and utilities are located in /bin. This folder is not for your personal scripts. See this guide on Linux directory Structure for more.

From Where should I put my Bash scripts? :

If you are the only person who is going to use this script, I recommend you move it to /home/roger/bin/.

If you have other user accounts and other people who customarily login to this computer are expected to use this script, I recommend you move it to /usr/local/bin/.

All these folders:

/bin/
/home/roger/bin/
/usr/local/bin

are in the the PATH environmental variable. So, you don't have to use cd /bin or cd bin followed by ./tasksheet.

You can just type tasksheet as if it is a command, like this:

roger@roger-Precision-Tower-3620:$ tasksheet

Note, the command prompt above indicates you are at the default location when you open a terminal while logged in as the user roger.

Hope this helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .