I used the following command to initiate a ssh connection to a remote macOS .Objective is to perform successful ssh login and mount a particular network share (via the mount.sh script).The script mount.sh when stored and executed on the remote macOS works fine.The script intakes user inputs and mounts the same into a user defined mount point.But am stuck whenever I would try to locally execute the script-mount.sh on the remote system via ssh.
In fact the ssh login works well but the script-mount.sh doesn't gets executed.
#!/bin/bash
read -p "Enter Username: " username
ssh $username@<Server IP> "$(< mount.sh)"
Any suggestions/advice to improve the code are welcome :).
The mount.sh script code :
#!/bin/bash
read -p "Enter the name of share mount :" lpmount
echo ""
read -p "Enter your User name: " username
echo ""
read -p "Enter the year (e.g. 2018,2019) :" year
mkdir /Gross/$lpmount
mount_smbfs //$username@<Server-IP>/Evi/$year /Gross/$lpmount
mount_status=$? # Checks if the mounting was successfull.
if [ $mount_status -eq 0 ]
then
echo ""
echo "Share mounted SUCCESSFULLY! at /Gross/$lpmount"
sleep 3
else
echo ""
echo " Share not mounted SUCCESSFULLY! at/Gross/$lpmount"
fi
mount.shdoing (can you share that script)?-xoption as that will show where it is failing !!mount.shis doing is:mount.shcould probably do thesshitself as something simple, likessh user@server mount ....mount.shis simple command then it should be passed asstdinbut just in case it's doing more than just command !!