Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:30:55+00:00 2026-06-17T22:30:55+00:00

I’m having an issue with my script. The variables X and Y are assigned

  • 0

I’m having an issue with my script. The variables X and Y are assigned the last octet of an IP address and work fine. Z is supposed to take X and Y and put the values into a new txt file.

X=$(ssh -i key.txt "$USER"@A.B.C.D "awk -F' ' '{print \$2}' /etc/openvpn/ccd/lastip.txt | awk -F'.' '{print \$4+4}'")
Y=$(ssh -i key.txt "$USER"@A.B.C.D "awk -F' ' '{print \$3}' /etc/openvpn/ccd/lastip.txt | awk -F'.' '{print \$4+4}'")
Z=$(ssh -i key.txt "$USER"@A.B.C.D "touch $NAME.txt | chmod 700 $NAME.txt mv $NAME.txt /etc/openvpn/ccd | echo -n "$X $Y" > /etc/openvpn/ccd/$NAME.txt")

I keep getting messages say permission denied:

mv: bash: /etc/openvpn/ccd/almost.txt: Permission denied
cannot move `almost.txt' to `/etc/openvpn/ccd/almost.txt': Permission denied

The directory exists and the permission for it are fine. How would I go about being able to move $NAME.txt into my desired directory?

EDIT: Even without Z=$() and using the command line, I still get permission denied errors

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:30:56+00:00Added an answer on June 17, 2026 at 10:30 pm

    This bit needs some work:

    touch $NAME.txt | chmod 700 $NAME.txt mv $NAME.txt /etc/openvpn/ccd | echo -n "$X $Y" > /etc/openvpn/ccd/$NAME.txt
    

    At minimum, you need to replace the pipes with semicolons, and one of the spaces too:

    touch $NAME.txt; chmod 700 $NAME.txt; mv $NAME.txt /etc/openvpn/ccd; echo -n "$X $Y" > /etc/openvpn/ccd/$NAME.txt
    

    It does not look plausible that you want to execute $NAME.txt; you should not use 700 but 600 permissions.

    Since you didn’t have a semicolon before the mv, the chmod program tried to change permissions on files mv, $NAME.txt a second time, and /etc/openvpn/ccd.

    Unless you are running as root, you should not be able to write in /etc/openvpn/ccd. However, you have not shown us the permissions on the current directory, though since touch appears to have worked, you can presumably write in that. Nor, at the time I wrote this, were the permissions on /etc/openvpn/ccd given — but see below.


    And, as John Kugleman notes in a comment, in the larger context where the command string I dissected is inside a set of double quotes, the double quotes around "$X $Y" should be escaped with backslashes:

    Z=$(ssh -i key.txt "$USER"@A.B.C.D "touch $NAME.txt; chmod 700 $NAME.txt; mv $NAME.txt /etc/openvpn/ccd; echo -n \"$X $Y\" > /etc/openvpn/ccd/$NAME.txt")
    

    Source of ‘no permission’ error

    Given that the permissions on /etc/openvpn/ccd are:

    drwxr-xr-x 2 root root 4096 2013-01-16 15:01 /etc/openvpn/ccd
    

    we can infer that you are not running as root and are not permitted to write in the directory. You may need to get permission to use sudo on the target machine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.